Skip to content

Instantly share code, notes, and snippets.

@pmichaud
Created April 19, 2013 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmichaud/5418133 to your computer and use it in GitHub Desktop.
Save pmichaud/5418133 to your computer and use it in GitHub Desktop.
pmichaud@kiwi:~/p6/nqp$ install/bin/parrot rpabench.pir
Each type run twice to compare "first to execute" bias
RPA, 1st run:
unshift(100000) = 3.46871209144592
shift(100000) = 3.46367216110229
push(100000) = 0.00369095802307129
pop(100000) = 0.00310397148132324
.unshift(100000) = 3.65762901306152
.shift(100000) = 3.64528703689575
.push(100000) = 0.0648429393768311
.pop(100000) = 0.0757210254669189
QRPA, 1st run:
unshift(100000) = 0.451287984848022
shift(100000) = 0.00315999984741211
push(100000) = 0.00389385223388672
pop(100000) = 0.00360417366027832
RPA, 2nd run:
unshift(100000) = 3.47330093383789
shift(100000) = 3.48381400108337
push(100000) = 0.00362396240234375
pop(100000) = 0.00354504585266113
.unshift(100000) = 3.61860084533691
.shift(100000) = 3.64137196540833
.push(100000) = 0.0652070045471191
.pop(100000) = 0.0763189792633057
QRPA, 2nd run:
unshift(100000) = 0.43984317779541
shift(100000) = 0.00329399108886719
push(100000) = 0.00365996360778809
pop(100000) = 0.00311017036437988
pmichaud@kiwi:~/p6/nqp$ cat rpabench.pir
.loadlib 'nqp_group'
.sub 'main' :main
say 'Each type run twice to compare "first to execute" bias'
say ''
say 'RPA, 1st run:'
$P0 = new ['ResizablePMCArray']
'benchvtable_shift'($P0, 100000)
$P0 = new ['ResizablePMCArray']
'benchvtable_push'($P0, 100000)
$P0 = new ['ResizablePMCArray']
'benchmethod_shift'($P0, 100000)
$P0 = new ['ResizablePMCArray']
'benchmethod_push'($P0, 100000)
say 'QRPA, 1st run:'
$P0 = new ['QRPA']
'benchvtable_shift'($P0, 100000)
$P0 = new ['QRPA']
'benchvtable_push'($P0, 100000)
say ''
say 'RPA, 2nd run:'
$P0 = new ['ResizablePMCArray']
'benchvtable_shift'($P0, 100000)
$P0 = new ['ResizablePMCArray']
'benchvtable_push'($P0, 100000)
$P0 = new ['ResizablePMCArray']
'benchmethod_shift'($P0, 100000)
$P0 = new ['ResizablePMCArray']
'benchmethod_push'($P0, 100000)
say 'QRPA, 2nd run:'
$P0 = new ['QRPA']
'benchvtable_shift'($P0, 100000)
$P0 = new ['QRPA']
'benchvtable_push'($P0, 100000)
.end
.sub 'benchvtable_shift'
.param pmc rpa
.param int n
sweep 1
$I0 = 0
$N0 = time
loop0:
unless $I0 < n goto done0
unshift rpa, rpa
inc $I0
goto loop0
done0:
$N1 = time
$N2 = $N1 - $N0
print " unshift("
print n
print ") = "
say $N2
sweep 1
$I0 = 0
$N0 = time
loop1:
unless $I0 < n goto done1
$P0 = shift rpa
inc $I0
goto loop1
done1:
$N1 = time
$N2 = $N1 - $N0
print " shift("
print n
print ") = "
say $N2
.end
.sub 'benchvtable_push'
.param pmc rpa
.param int n
sweep 1
$I0 = 0
$N0 = time
loop0:
unless $I0 < n goto done0
push rpa, rpa
inc $I0
goto loop0
done0:
$N1 = time
$N2 = $N1 - $N0
print " push("
print n
print ") = "
say $N2
sweep 1
$I0 = 0
$N0 = time
loop1:
unless $I0 < n goto done1
$P0 = pop rpa
inc $I0
goto loop1
done1:
$N1 = time
$N2 = $N1 - $N0
print " pop("
print n
print ") = "
say $N2
.end
.sub 'benchmethod_shift'
.param pmc rpa
.param int n
sweep 1
$I0 = 0
$N0 = time
loop0:
unless $I0 < n goto done0
rpa.'unshift'(rpa)
inc $I0
goto loop0
done0:
$N1 = time
$N2 = $N1 - $N0
print " .unshift("
print n
print ") = "
say $N2
sweep 1
$I0 = 0
$N0 = time
loop1:
unless $I0 < n goto done1
$P0 = rpa.'shift'()
inc $I0
goto loop1
done1:
$N1 = time
$N2 = $N1 - $N0
print " .shift("
print n
print ") = "
say $N2
.end
.sub 'benchmethod_push'
.param pmc rpa
.param int n
sweep 1
$I0 = 0
$N0 = time
loop0:
unless $I0 < n goto done0
rpa.'push'(rpa)
inc $I0
goto loop0
done0:
$N1 = time
$N2 = $N1 - $N0
print " .push("
print n
print ") = "
say $N2
sweep 1
$I0 = 0
$N0 = time
loop1:
unless $I0 < n goto done1
$P0 = rpa.'pop'()
inc $I0
goto loop1
done1:
$N1 = time
$N2 = $N1 - $N0
print " .pop("
print n
print ") = "
say $N2
.end
pmichaud@kiwi:~/p6/nqp$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment