Created
June 20, 2015 07:49
-
-
Save fcamel/c013c6ca4279ba1c937f to your computer and use it in GitHub Desktop.
benchmark dictionary get/set for node.js, CPython2, pypy
This file contains hidden or 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
$ cat h.js | |
n = 100000000; | |
s = {}; | |
key = "abc"; | |
s[key] = 0; | |
for (i = 0; i < n; i++) { | |
s[key] += 1; | |
} | |
console.log(s[key]); | |
$ time node h.js | |
100000000 | |
real 0m12.261s | |
user 0m12.236s | |
sys 0m0.020s | |
$ cat h.py | |
n = 100000000; | |
s = {}; | |
key = "abc"; | |
s[key] = 0; | |
for _ in xrange(n): | |
s[key] += 1 | |
print s[key] | |
$ time python h.py | |
100000000 | |
real 0m15.650s | |
user 0m15.627s | |
sys 0m0.018s | |
$ time pypy h.py | |
100000000 | |
real 0m1.781s | |
user 0m1.756s | |
sys 0m0.021s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment