Commits

Miki Tebeka committed f35bbda

Starting

Comments (0)

Files changed (1)

+#!/usr/bin/env python
+
+from time import time
+from subprocess import call
+from os import environ, stat
+from stat import S_IXUSR
+from os.path import isfile, join
+
+def which(name):
+    for path in environ["PATH"].split(":"):
+        full = join(path, name)
+        if not isfile(full):
+            continue
+        if stat(full).st_mode & S_IXUSR:
+            return full
+
+
+def simple(name):
+    full = which(name)
+    assert full, "can't find %s" % name
+
+    return { "name" : name.title(), "command" : [full, "/dev/null"]}
+
+scripts = [
+    simple("python"),
+    simple("ruby"),
+    simple("perl"),
+]
+
+def timeit(command):
+    start = time()
+    call(command, shell=0)
+    end = time()
+
+    return end - start
+
+def run():
+    runtimes = []
+    for script in scripts:
+        start = time()
+        runtimes.append((timeit(script["command"]), script["name"]))
+
+    runtimes.sort()
+    for runtime, name in runtimes:
+        print "%-7s: %f" % (name, runtime)
+
+if __name__ == "__main__":
+    run()