Skip to content

Instantly share code, notes, and snippets.

@pcarrier
Created September 26, 2012 21:07
Show Gist options
  • Select an option

  • Save pcarrier/3790598 to your computer and use it in GitHub Desktop.

Select an option

Save pcarrier/3790598 to your computer and use it in GitHub Desktop.
Running times
Assembly: 0.000169164 * 10000 = 1.691642309
C (diet, static): 0.000178204 * 5000 = 0.891020651
C (musl, static): 0.000194115 * 5000 = 0.970577889
C (musl, dynamic): 0.000342195 * 5000 = 1.710977786
C (static): 0.000090583 * 5000 = 0.452919855
C (dynamic): 0.000702688 * 3000 = 2.108064792
Fortran (static): 0.000455501 * 5000 = 2.277508594
Fortran (dynamic): 0.001639982 * 2000 = 3.279964656
Haskell (static): 0.001355104 * 2000 = 2.710208459
Haskell (dynamic): 0.002697174 * 1000 = 2.697174090
OCaml: 0.001517076 * 1000 = 1.517076981
Go: 0.003836930 * 1000 = 3.836930851
lua: 0.002343486 * 1000 = 2.343486340
BusyBox shell: 0.000697259 * 3000 = 2.091778592
dash: 0.001224925 * 1000 = 1.224925060
mksh: 0.001850628 * 1000 = 1.850628543
plan9 rc: 0.002187443 * 1000 = 2.187443115
nawk: 0.001488329 * 1000 = 1.488329756
awk (GNU): 0.006105896 * 500 = 3.052948319
tcl: 0.007309309 * 500 = 3.654654736
Bash: 0.007432038 * 500 = 3.716019380
Zsh: 0.007343697 * 500 = 3.671848818
tcsh: 0.009758095 * 500 = 4.879047883
PHP5: 0.008490535 * 200 = 1.698107155
Perl 5: 0.003812102 * 500 = 1.906051064
Chicken (compiled): 0.009398219 * 200 = 1.879643984
Chicken (script): 0.009592809 * 200 = 1.918561815
SBCL (compiled): 0.008679940 * 100 = 0.867994098
SBCL (script): 0.007080823 * 100 = 0.708082340
MRI 1.9: 0.013838002 * 200 = 2.767600581
Emacs: 0.020819761 * 100 = 2.081976107
V8: 0.019428874 * 100 = 1.942887482
Node.JS: 0.026732453 * 100 = 2.673245378
cpython 2: 0.020974210 * 100 = 2.097421064
cpython 3: 0.042390707 * 50 = 2.119535378
Java (jamvm): 0.015089572 * 100 = 1.508957216
Java 7 (Oracle): 0.050786282 * 50 = 2.539314147
Mono (C#): 0.012879172 * 100 = 1.287917251
Code:
https://github.com/pcarrier/benchmarking-uselessness
Observations:
- The kernel is an amazing beast. Look at how fast you can create
damn processes.
- Dynamic linking and the glibc are much more expensive than I'd
thought. The assembly binary gets ran roughly 4 times faster than
the dynamically linked C code.
- Even the statically linked Busybox shell manages to be faster!
I'd like to check which libc it is linked to.
- Oh my god Python 3 is so slooow! I have a hard time explaining
how it can be _that_ slow. Whilst Python 2 opens 65 files, Python
3 opens 85. Including a C header, /usr/include/python3.2mu/pyconfig.h.
I assume it's parsed!?
strace /usr/bin/python3 empty >/dev/null 2>&1|grep -E 'open.* = [^-]'|wc -l
- Even though it's the slowest, a modern JVM is impressively fast
with a modern CPU. Similar tests were much slower with both Java 6
and Java 7 under both Snow Leopard and Lion, I'd like to explain why.
- I mean seriously, SERIOUSLY, Python 3 is closer to Java 7 than it is
to Python 2 ! One can use the JVM for short-lived command-line utilities.
Full disclosure, I already do that :)
- Chicken has a non-negligible initialization time, which doesn't vary
much with compilation.
- Emacs is much faster than I would have thought. I was strongly biased.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment