You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to say this is a great pure Lua approach to doing b64 encoding/decoding. We really need this to do b32 decoding and b64 url safe decoding and finding that easily in other modules is a challenge!
When compared to other modules (such as https://github.com/iskolbin/lbase64), the encoding/decoding performance looks like it could use some attention. I don't do much Lua so not sure how much help I would be here. Here is a benchmark on my M2 MBP:
basexx=require"basexx"base64=require"base64"localunits= {
['seconds'] =1,
['milliseconds'] =1000,
['microseconds'] =1000000,
['nanoseconds'] =1000000000
}
functionbenchmark(unit, decPlaces, n, f, ...)
localelapsed=0localmultiplier=units[unit]
fori=1, ndolocalnow=os.clock()
f(...)
elapsed=elapsed+ (os.clock() -now)
endprint(string.format('Benchmark results: %d function calls | %.'..decPlaces..'f %s elapsed | %.'..decPlaces..'f %s avg execution time.', n, elapsed*multiplier, unit, (elapsed/n) *multiplier, unit))
endprint("Benchmarking base64.decode...")
benchmark('milliseconds', 5, 10000, base64.decode, "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=")
print("Benchmarking basexx.from_base64...")
benchmark('milliseconds', 5, 10000, basexx.from_base64, "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=")
print("Benchmarking base64.encode...")
benchmark('milliseconds', 5, 10000, base64.encode, "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.")
print("Benchmarking basexx.to_base64...")
benchmark('milliseconds', 5, 10000, basexx.to_base64, "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.")
I'd like to say this is a great pure Lua approach to doing b64 encoding/decoding. We really need this to do b32 decoding and b64 url safe decoding and finding that easily in other modules is a challenge!
When compared to other modules (such as https://github.com/iskolbin/lbase64), the encoding/decoding performance looks like it could use some attention. I don't do much Lua so not sure how much help I would be here. Here is a benchmark on my M2 MBP:
Results:
So it's around 20-25x slower. Any thoughts on what can be done to improve the performance?
The text was updated successfully, but these errors were encountered: