Created
November 9, 2014 15:28
-
-
Save benkamphaus/f8c97af7bb9eb5c9b03a to your computer and use it in GitHub Desktop.
Preliminary transducer benchmarks in Python2 and PyPy
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
Benchmarks at: https://github.com/cognitect-labs/transducers-python/blob/master/tests/benchmark.py | |
transducers-python git/master | |
❯ python tests/benchmark.py | |
Avg. time for transducers.transducers with T.replace({0:1, 100:200, 1000:500}) is: 68.4194946289 | |
Avg. time for tests.genducers with G.replace({0:1, 100:200, 1000:500}) is: 37.8649584961 | |
Avg. time for transducers.transducers with T.take(10000) is: 8.898671875 | |
Avg. time for tests.genducers with G.take(10000) is: 3.86192871094 | |
Avg. time for transducers.transducers with T.dedupe is: 0.779968261719 | |
Avg. time for tests.genducers with G.dedupe is: 0.304665527344 | |
Avg. time for transducers.transducers with T.keep(lambda x: x if x > 100 else None) is: 78.3976171875 | |
Avg. time for tests.genducers with G.keep(lambda x: x if x > 100 else None) is: 47.9900317383 | |
Avg. time for transducers.transducers with T.remove(lambda x: x % 4) is: 60.8669775391 | |
Avg. time for tests.genducers with G.remove(lambda x: x % 4) is: 26.7044799805 | |
Avg. time for transducers.transducers with T.partition_by(lambda x: x%2) is: 1.66807128906 | |
Avg. time for tests.genducers with G.partition_by(lambda x: x%2) is: 0.860988769531 | |
Avg. time for transducers.transducers with T.keep_indexed(lambda i, x: i*x if i%4 else None) is: 91.0018310547 | |
Avg. time for tests.genducers with G.keep_indexed(lambda i, x: i*x if i%4 else None) is: 49.7577807617 | |
Avg. time for transducers.transducers with T.filter(lambda x: x%2) is: 68.1568676758 | |
Avg. time for tests.genducers with G.filter(lambda x: x%2) is: 35.5950634766 | |
Avg. time for transducers.transducers with T.random_sample(0.4) is: 57.1796899414 | |
Avg. time for tests.genducers with G.random_sample(0.4) is: 23.9054370117 | |
Avg. time for transducers.transducers with T.mapcat(reversed) is: 2.62831054687 | |
Avg. time for tests.genducers with G.mapcat(reversed) is: 3.08866210937 | |
Avg. time for transducers.transducers with T.cat is: 2.52930175781 | |
Avg. time for tests.genducers with G.cat is: 2.90984130859 | |
Avg. time for transducers.transducers with T.map(lambda x: x*x) is: 74.955637207 | |
Avg. time for tests.genducers with G.map(lambda x: x*x) is: 47.4226147461 | |
Avg. time for transducers.transducers with T.partition_all(10) is: 7.33654785156 | |
Avg. time for tests.genducers with G.partition_all(10) is: 2.93203369141 | |
Avg. time for transducers.transducers with T.take_while(lambda x: x < 1000) is: 0.743635253906 | |
Avg. time for tests.genducers with G.take_while(lambda x: x < 1000) is: 0.428486328125 | |
Avg. time for transducers.transducers with T.drop_while(lambda x: x < 1500) is: 69.75203125 | |
Avg. time for tests.genducers with G.drop_while(lambda x: x < 1500) is: 36.0358276367 | |
Avg. time for transducers.transducers with T.drop(1000) is: 68.8376782227 | |
Avg. time for tests.genducers with G.drop(1000) is: 39.2205493164 | |
Avg. time for transducers.transducers with T.take_nth(4) is: 65.4745751953 | |
Avg. time for tests.genducers with G.take_nth(4) is: 21.0029931641 | |
Average for large compose for Generators: 58.0484130859 ms. | |
Average for large compose for Transducers: 113.163024902 ms. | |
transducers-python git/master | |
❯ pypy tests/benchmark.py | |
Avg. time for transducers.transducers with T.replace({0:1, 100:200, 1000:500}) is: 5.42088623047 | |
Avg. time for tests.genducers with G.replace({0:1, 100:200, 1000:500}) is: 11.5764038086 | |
Avg. time for transducers.transducers with T.take(10000) is: 0.878977050781 | |
Avg. time for tests.genducers with G.take(10000) is: 0.595402832031 | |
Avg. time for transducers.transducers with T.dedupe is: 0.218110351562 | |
Avg. time for tests.genducers with G.dedupe is: 0.151977539062 | |
Avg. time for transducers.transducers with T.keep(lambda x: x if x > 100 else None) is: 4.58188720703 | |
Avg. time for tests.genducers with G.keep(lambda x: x if x > 100 else None) is: 5.98572509766 | |
Avg. time for transducers.transducers with T.remove(lambda x: x % 4) is: 4.14598144531 | |
Avg. time for tests.genducers with G.remove(lambda x: x % 4) is: 4.53557617188 | |
Avg. time for transducers.transducers with T.partition_by(lambda x: x%2) is: 0.31029296875 | |
Avg. time for tests.genducers with G.partition_by(lambda x: x%2) is: 0.199262695312 | |
Avg. time for transducers.transducers with T.keep_indexed(lambda i, x: i*x if i%4 else None) is: 10.3289624023 | |
Avg. time for tests.genducers with G.keep_indexed(lambda i, x: i*x if i%4 else None) is: 8.48126220703 | |
Avg. time for transducers.transducers with T.filter(lambda x: x%2) is: 5.70240234375 | |
Avg. time for tests.genducers with G.filter(lambda x: x%2) is: 8.25206542969 | |
Avg. time for transducers.transducers with T.random_sample(0.4) is: 7.53529296875 | |
Avg. time for tests.genducers with G.random_sample(0.4) is: 8.94577880859 | |
Avg. time for transducers.transducers with T.mapcat(reversed) is: 0.31595703125 | |
Avg. time for tests.genducers with G.mapcat(reversed) is: 0.582822265625 | |
Avg. time for transducers.transducers with T.cat is: 0.356645507812 | |
Avg. time for tests.genducers with G.cat is: 0.629418945312 | |
Avg. time for transducers.transducers with T.map(lambda x: x*x) is: 5.82237060547 | |
Avg. time for tests.genducers with G.map(lambda x: x*x) is: 6.66640380859 | |
Avg. time for transducers.transducers with T.partition_all(10) is: 0.778024902344 | |
Avg. time for tests.genducers with G.partition_all(10) is: 0.870681152344 | |
Avg. time for transducers.transducers with T.take_while(lambda x: x < 1000) is: 0.0800708007813 | |
Avg. time for tests.genducers with G.take_while(lambda x: x < 1000) is: 0.0990966796875 | |
Avg. time for transducers.transducers with T.drop_while(lambda x: x < 1500) is: 7.70324951172 | |
Avg. time for tests.genducers with G.drop_while(lambda x: x < 1500) is: 12.0406323242 | |
Avg. time for transducers.transducers with T.drop(1000) is: 8.22435302734 | |
Avg. time for tests.genducers with G.drop(1000) is: 8.41688476562 | |
Avg. time for transducers.transducers with T.take_nth(4) is: 8.72201904297 | |
Avg. time for tests.genducers with G.take_nth(4) is: 5.74761962891 | |
Average for large compose for Generators: 16.3901269531 ms. | |
Average for large compose for Transducers: 9.79808349609 ms. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment