Hey Aapo,
Thank you for taking the time to try it out and for playing with the
benchmarks. I am glad you were able to confirm them.
> faster in generation except with generate_time function
I believe generation of v1 UUIDs would be faster than v4 indeed. I will
evaluate implementing v1 UUID generation as well in resty-jit-uuid, I am
not yet sure about the feasibility/efficiency of it.
> I also changed the order a bit of that bench table, and that changed
> a results a bit
Interesting, I will give this a try and maybe improve the benchmarking
script.
> maybe I should add this as a fallback to lua-resty-uuid for
> Windows platforms where the libuuid dependency is usually a problem.
That is a good use-case indeed, precisely one of those I had in mind :)
Regards,
Thibault
On 4/21/16 5:53 AM, Aapo Talvensaari wrote:
On Thursday, 21 April 2016 05:02:30 UTC+3, Thibault Charbonnier wrote:
What started as a LuaJIT script to generate UUIDs became lua-resty-
jit-uuid:
https://github.com/thibaultCha/lua-resty-jit-uuid
<https://github.com/thibaultCha/lua-resty-jit-uuid>
According to the benchmarks I ran, it appears to be more efficient
than the
FFI and C bindings. It uses math.random() (which as we know is enhanced
by LuaJIT) and the BitOp module, and is optimized for use in ngx_lua.
Thanks Thibault,
I can confirm your benchmarks, your lib is in general faster than
everything else.
libuuid supports 3 different algorightms. On my tests it seems that your
lib is
faster in generation except with generate_time function where your lib and
the FFI version are about the same (I modified the bench code to use
generate_time with FFI binding instead, here are results from my mac):
LuaJIT 2.1.0-beta1 with 1e+06 UUIDs
UUID v4 (random) generation
1. FFI binding took: 0.100180s -1%
2. resty-jit-uuid took: 0.101588s +0%
I also changed the order a bit of that bench table, and that changed a
results a bit
(I think they are still inside the error margin):
1. FFI binding took: 0.100896s -10%
2. resty-jit-uuid took: 0.113080s +0%
Great work indeed, maybe I should add this as a fallback to
lua-resty-uuid for
Windows platforms where the libuuid dependency is usually a problem.
Thanks for contributing this!.