Skip to content

Instantly share code, notes, and snippets.

@philippbayer
Created April 2, 2012 04:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philippbayer/2280733 to your computer and use it in GitHub Desktop.
Save philippbayer/2280733 to your computer and use it in GitHub Desktop.
Julia vs. Python 2.7 Parsing
$ python2.7 parse.py
0.797344923019
$ julia parse.jl
16789.66212272644
o.O
Tested against a 91mb big tab-delimited input-file.
With a 800mb big file:
$ python parse.py
6.59492301941
$ julia parse.jl
129588.43898773193
-----------------------------------------------
Python-code:
-----------------------------------------------
import time
def parse():
file_handle = open("./backParsedTapidorContigs.csv")
for line in file_handle:
line = line.split("\t")
tmin = float("inf")
for i in range(5):
t = time.time()
parse()
t = time.time()-t
if t < tmin:
tmin = t
print tmin
-----------------------------------------------
Julia-code (macro taken from https://github.com/JuliaLang/julia/blob/master/test/perf/perf.jl)
-----------------------------------------------
macro timeit(ex,name)
quote
t = Inf
for i=1:5
t = min(t, @elapsed $ex)
end
println(t*1000)
end
end
function parse()
file = LineIterator(open("./backParsedTapidorContigs.csv"))
for line in file
split(line, "\t")
end
end
@timeit parse() "parse"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment