Skip to content

Instantly share code, notes, and snippets.

@pmichaud
Created April 19, 2013 02:25
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/5417664 to your computer and use it in GitHub Desktop.
Save pmichaud/5417664 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.44259786605835
shift(100000) = 3.45256185531616
push(100000) = 0.00364995002746582
pop(100000) = 0.0030970573425293
.unshift(100000) = 3.64706993103027
.shift(100000) = 3.68111896514893
.push(100000) = 0.160858869552612
.pop(100000) = 0.0827410221099854
QRPA, 1st run:
unshift(100000) = 0.454362154006958
shift(100000) = 0.00335597991943359
push(100000) = 0.00391721725463867
pop(100000) = 0.00312519073486328
RPA, 2nd run:
unshift(100000) = 3.40240907669067
shift(100000) = 3.41924595832825
push(100000) = 0.00361108779907227
pop(100000) = 0.00310301780700684
.unshift(100000) = 3.63127398490906
.shift(100000) = 3.73593401908875
.push(100000) = 0.0673990249633789
.pop(100000) = 0.0806920528411865
QRPA, 1st run:
unshift(100000) = 0.45409893989563
shift(100000) = 0.00304913520812988
push(100000) = 0.00359797477722168
pop(100000) = 0.00325703620910645
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, 1st 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
$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
$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
$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
$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
$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
$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
$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
$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