Created
July 15, 2014 10:33
-
-
Save tombentley/fff50f32ed8c5d9f769a to your computer and use it in GitHub Desktop.
Some benchmark results comparing native Tuple with Ceylon tuple
We can make this file beautiful and searchable if this error is corrected: It looks like row 33 should actually have 1 column, instead of 4 in line 32.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name iterations result time/ms memory usage/KiBi | |
allocate size=3 10000000 10000000 2290.845615 253043 | |
allocate size=1 1000000 1000000 110.713352 624244 | |
allocate size=3 1000000 1000000 190.109012 1213297 | |
allocate size=10 1000000 1000000 535.848205 687878 | |
allocate size=100 1000000 1000000 4807.714236 352313 | |
allocate size=1000 100000 100000 5104.72015 735709 | |
iteration size=3 1000000 6000006 64.324978 34432 | |
iteration size=1 1000000 1000001 45.443707 34405 | |
iteration size=3 1000000 6000006 34.835159 34405 | |
iteration size=10 1000000 55000055 71.523127 34405 | |
iteration size=100 1000000 5050005050 294.185318 34405 | |
iteration size=1000 1000000 500500500500 6376.321321 34405 | |
firstIndex size=3 1000000 3000003 7.673766 34468 | |
firstIndex size=1 1000000 1000001 18.060779 34445 | |
firstIndex size=3 1000000 3000003 1.268869 34445 | |
firstIndex size=10 1000000 10000010 1.174724 34445 | |
firstIndex size=100 1000000 100000100 2.355873 34445 | |
firstIndex size=1000 1000000 1000001000 2.22073 34445 | |
middleIndex size=3 1000000 0 33.691864 34508 | |
middleIndex size=1 1000000 0 40.665615 34485 | |
middleIndex size=3 1000000 0 13.377879 34485 | |
middleIndex size=10 1000000 0 47.607518 34485 | |
middleIndex size=100 1000000 0 381.798524 34485 | |
middleIndex size=1000 1000000 0 6110.354862 34485 | |
reifiedIs size=3 1000000 0 1478.367857 216263 | |
reifiedIs size=1 1000000 0 2169.931662 216816 | |
reifiedIs size=3 1000000 0 2164.248361 216704 | |
reifiedIs size=10 1000000 0 2179.791657 216704 | |
reifiedIs size=100 1000000 0 2161.020806 216704 | |
reifiedIs size=1000 1000000 0 2161.016616 216704 | |
total time: 39770.446301ms | |
PS Scavenge count=109, time=218ms, pools={ PS Eden Space, PS Survivor Space } | |
PS MarkSweep count=30, time=744ms, pools={ PS Eden Space, PS Survivor Space, PS Old Gen, PS Perm Gen } |
We can make this file beautiful and searchable if this error is corrected: It looks like row 32 should actually have 1 column, instead of 4 in line 31.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name iterations result time/ms memory usage/KiBi | |
allocate size=3 10000000 10000000 2846.778323 660075 | |
allocate size=1 1000000 1000000 122.139824 592386 | |
allocate size=3 1000000 1000000 244.797098 169623 | |
allocate size=10 1000000 1000000 710.644139 628216 | |
allocate size=100 1000000 1000000 8858.155523 278799 | |
allocate size=1000 100000 100000 34764.632772 768673 | |
iteration size=3 1000000 6000006 34.954941 33827 | |
iteration size=1 1000000 1000001 25.091244 33803 | |
iteration size=3 1000000 6000006 6.090404 33803 | |
iteration size=10 1000000 55000055 11.66615 33803 | |
iteration size=100 1000000 5050005050 121.93491 33803 | |
iteration size=1000 1000000 500500500500 2519.69037 33803 | |
firstIndex size=3 1000000 3000003 8.57185 33838 | |
firstIndex size=1 1000000 1000001 15.164201 33815 | |
firstIndex size=3 1000000 3000003 1.587902 33815 | |
firstIndex size=10 1000000 10000010 1.573236 33815 | |
firstIndex size=100 1000000 100000100 1.59356 33815 | |
firstIndex size=1000 1000000 1000001000 1.578264 33815 | |
middleIndex size=3 1000000 0 10.212133 33849 | |
middleIndex size=1 1000000 0 17.826046 33826 | |
middleIndex size=3 1000000 0 2.011208 33826 | |
middleIndex size=10 1000000 0 1.972167 33826 | |
middleIndex size=100 1000000 0 1.966021 33826 | |
middleIndex size=1000 1000000 0 1.959735 33826 | |
reifiedIs size=3 1000000 0 3839.188151 167385 | |
reifiedIs size=1 1000000 0 2978.087763 100614 | |
reifiedIs size=3 1000000 0 5564.085622 167376 | |
reifiedIs size=10 1000000 0 12430.646006 389926 | |
reifiedIs size=100 1000000 0 228714.683666 747948 | |
total time: 304948.409892ms | |
PS Scavenge count=317, time=545ms, pools={ PS Eden Space, PS Survivor Space } | |
PS MarkSweep count=29, time=699ms, pools={ PS Eden Space, PS Survivor Space, PS Old Gen, PS Perm Gen } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.management{ManagementFactory} | |
import ceylon.interop.java{CeylonIterable} | |
import java.lang{Runtime} | |
import java.util{Arrays} | |
class BenchmarkResult<out Result>(name, iterations, result, nanoseconds, memory) { | |
shared String name; | |
shared Integer iterations; | |
shared Result result; | |
shared Integer nanoseconds; | |
shared Integer memory; | |
} | |
void printHeader() { | |
print("name\titerations\tresult\ttime/ms\tmemory usage/KiBi"); | |
} | |
void printLine(BenchmarkResult<Object> result) { | |
print("``result.name``\t``result.iterations``\t``result.result``\t``result.nanoseconds/1_000_000.0``\t``result.memory/1_024``"); | |
} | |
"Allocate (by consing) a tuple [0, 1, ..tupleSize-1] and return it." | |
Integer[] allocate(Integer tupleSize) { | |
variable Integer[] tail = []; | |
for (ii in 0..tupleSize) { | |
tail = [ii, *tail]; | |
} | |
return tail; | |
} | |
"Do `iterations` allocations, summing the last element." | |
BenchmarkResult<Integer> allocateTest(Integer tupleSize, Integer iterations) { | |
(ManagementFactory.memoryMXBean).gc(); | |
variable value sum = 0; | |
Integer t0 = system.nanoseconds; | |
for (it in 0:iterations) { | |
sum += allocate(tupleSize)[tupleSize-1] else 0; | |
} | |
return BenchmarkResult("allocate size=``tupleSize``", | |
iterations, | |
sum, | |
system.nanoseconds-t0, | |
usedMem()); | |
//print("allocate size=``tupleSize``, iterations=``iterations``, result=``sum``, time=``(system.nanoseconds-t0)/1_000_000.0``ms, usedmem=``usedMem()/1_024``KiB"); | |
} | |
"sum a tuple containing 0..tupleSize-1, `iterations` times accessing each element via the iterator()." | |
BenchmarkResult<Integer> iterationTest(Integer tupleSize, Integer iterations) { | |
(ManagementFactory.memoryMXBean).gc(); | |
Integer[] tuple = allocate(tupleSize); | |
variable Integer sum = 0; | |
Integer t0 = system.nanoseconds; | |
for (ii in 0..iterations) { | |
for (o in tuple) { | |
sum += o; | |
} | |
} | |
return BenchmarkResult("iteration size=``tupleSize``", | |
iterations, | |
sum, | |
system.nanoseconds-t0, | |
usedMem()); | |
//print("iterate size=``tupleSize``, iterations=``iterations``, result=``sum``, time=``(system.nanoseconds-t0)/1_000_000.0``ms, usedmem=``usedMem()/1_024``KiB"); | |
} | |
"get the first element `iterations` times" | |
BenchmarkResult<Integer> firstTest(Integer tupleSize, Integer iterations) { | |
(ManagementFactory.memoryMXBean).gc(); | |
Integer[] tuple = allocate(tupleSize); | |
variable Integer sum = 0; | |
value middleIndex = 0; | |
Integer t0 = system.nanoseconds; | |
for (ii in 0..iterations) { | |
sum += tuple.getFromFirst(middleIndex) else 0; | |
} | |
return BenchmarkResult("firstIndex size=``tupleSize``", | |
iterations, | |
sum, | |
system.nanoseconds-t0, | |
usedMem()); | |
//print("firstIndex size=``tupleSize``, iterations=``iterations``, result=``sum``, time=``(system.nanoseconds-t0)/1_000_000.0``ms, usedmem=``usedMem()/1_024``KiB"); | |
} | |
"get the middle element `iterations` times" | |
BenchmarkResult<Integer> middleTest(Integer tupleSize, Integer iterations) { | |
(ManagementFactory.memoryMXBean).gc(); | |
Integer[] tuple = allocate(tupleSize); | |
variable Integer sum = 0; | |
value middleIndex = tupleSize+1/2; | |
Integer t0 = system.nanoseconds; | |
for (ii in 0..iterations) { | |
sum += tuple.getFromFirst(middleIndex) else 0; | |
} | |
return BenchmarkResult("middleIndex size=``tupleSize``", | |
iterations, | |
sum, | |
system.nanoseconds-t0, | |
usedMem()); | |
//print("middleIndex size=``tupleSize``, iterations=``iterations``, result=``sum``, time=``(system.nanoseconds-t0)/1_000_000.0``ms, usedmem=``usedMem()/1_024``KiB"); | |
} | |
"get the middle element `iterations` times" | |
BenchmarkResult<Integer> reificationTest(Integer tupleSize, Integer iterations) { | |
(ManagementFactory.memoryMXBean).gc(); | |
Integer[] tuple = allocate(tupleSize); | |
variable Integer sum = 0; | |
Integer t0 = system.nanoseconds; | |
for (ii in 0..iterations) { | |
sum += punk(tuple) then 0 else 1; | |
} | |
return BenchmarkResult("reifiedIs size=``tupleSize``", | |
iterations, | |
sum, | |
system.nanoseconds-t0, | |
usedMem()); | |
//print("reificationTest size=``tupleSize``, iterations=``iterations``, result=``sum``, time=``(system.nanoseconds-t0)/1_000_000.0``ms, usedmem=``usedMem()/1_024``KiB"); | |
} | |
void run() { | |
Integer t0 = system.nanoseconds; | |
value allocateTests => [[allocateTest, 3, 10_000_000],//warmup | |
[allocateTest, 1, 1_000_000], | |
[allocateTest, 3, 1_000_000], | |
[allocateTest, 10, 1_000_000], | |
[allocateTest, 100, 1_000_000], | |
[allocateTest, 1000, 100_000]]; | |
value iterationTests => [[iterationTest, 3, 1_000_000],//warmup | |
[iterationTest, 1, 1_000_000], | |
[iterationTest, 3, 1_000_000], | |
[iterationTest, 10, 1_000_000], | |
[iterationTest, 100, 1_000_000], | |
[iterationTest, 1000, 1_000_000]]; | |
value firstTests => [[firstTest, 3, 1_000_000],//warmup | |
[firstTest, 1, 1_000_000], | |
[firstTest, 3, 1_000_000], | |
[firstTest, 10, 1_000_000], | |
[firstTest, 100, 1_000_000], | |
[firstTest, 1000, 1_000_000]]; | |
value middleTests => [[middleTest, 3, 1_000_000],//warmup | |
[middleTest, 1, 1_000_000], | |
[middleTest, 3, 1_000_000], | |
[middleTest, 10, 1_000_000], | |
[middleTest, 100, 1_000_000], | |
[middleTest, 1000, 1_000_000]]; | |
value reificationTests => [[reificationTest, 3, 1_000_000],//warmup | |
[reificationTest, 1, 1_000_000], | |
[reificationTest, 3, 1_000_000], | |
[reificationTest, 10, 1_000_000], | |
[reificationTest, 100, 1_000_000]//, | |
//[reificationTest, 1000, 1_000_000] | |
]; | |
printHeader(); | |
for (test in allocateTests) { | |
printLine(test[0](test[1], test[2])); | |
//print("used memory: ``usedMem()/1_024``KiB"); | |
} | |
for (test in iterationTests) { | |
printLine(test[0](test[1], test[2])); | |
//print("used memory: ``usedMem()/1_024``KiB"); | |
} | |
for (test in firstTests) { | |
printLine(test[0](test[1], test[2])); | |
//print("used memory: ``usedMem()/1_024``KiB"); | |
} | |
for (test in middleTests) { | |
printLine(test[0](test[1], test[2])); | |
//print("used memory: ``usedMem()/1_024``KiB"); | |
} | |
for (test in reificationTests) { | |
printLine(test[0](test[1], test[2])); | |
//print("used memory: ``usedMem()/1_024``KiB"); | |
} | |
print("total time: ``(system.nanoseconds-t0)/1_000_000.0``ms"); | |
value beans = ManagementFactory.garbageCollectorMXBeans; | |
variable value ii = 0; | |
while (ii < beans.size()) { | |
value bean = beans.get(ii); | |
print("``bean.name`` count=``bean.collectionCount``, time=``bean.collectionTime``ms, pools=``bean.memoryPoolNames.iterable``"); | |
ii++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment