lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

I rewrote a C tool entirely in lua. The tool iterates over the lines
in a file and saves them
in a table (probes). Once that is done, it iterates over the lines of
another file and
looks for substrings on those lines to see if they match any key in
the previously created
table.

With a test case (file1: 1M lines, file2: 5million lines) the C
version takes 45secs to
1 min. The lua version (luajit) takes 3:45 min. I'd like to see how
much I can reduce
the runtime by improving my lua code. I am open to rewrite certain
parts in C to help
speed up the execution but before I want to get the most of my pure lua code.

There are a couple of functions that take most of the computation
cycles:

local function screen_reads(args, probes)
local slide_over_read(read, pl)

The first one iterates over the input file and calls
slide_over_reads() per each
line.

Full code here: goo.gl/wflFm

Any feeback?

Thanks,
-drd

P.S: Thanks to the people in #lua @freenode for their feedback in the
first parts of
my tool.