Seriously? January 15, 2014 at 12:45 am

Sometimes I take things “to extreme.” Given a “coding challenge” and way too much extra time on my hands…

I needed a natural Lua base64 encoding and wasn’t happy with the ones I found.

Using the same base file (818K) as input (on the same machine) I started at around 1.3 seconds and was able to tune that version to just over a full second. After a good night sleep and a little competition (in the form of finding another implementation performing slightly better) I tuned the code again eliminating about 50% of the processing overhead. This is already crazy, but I decided that I really needed to improve the performance even further. In “natural Lua” I am able to encode the same file in about 350ms. I am not certain if I can find any more areas to improve, but my thinking was already in that direction before my last “inspiration.”

That is not “incredible” performance in the “real world.” However, with the constraints of the system I am working in, the performance increase is pretty cool (IMO). I can’t say my implementation is “the best ever.” There are a crap load of implementations floating out there. There could be another that performs considerably better. I am wondering if a generated table could remove all of the math in the main loop. The problem is diminishing returns. At the moment I have (more than) good enough
performance for my immediate needs.

Comments are closed.