Tieske / uuid

A pure Lua uuid generator (modified from a Rackspace module)
http://tieske.github.io/uuid/
137 stars 50 forks source link

docs: fix typo in latest note #3

Closed thibaultcha closed 8 years ago

thibaultcha commented 8 years ago

Very minor but came through it and GitHub makes it too easy to propose changes:


On a side note, I have run some tests locally because I wanted to compare the performance between this Lua implementation and the C wrapping from lua-uuid, and while doing so, I noticed that this module does not cache the functions attached to global variables it uses, especially math.random, but also others used in the bitwise and int2hex functions.

I have noticed that this simple code:

local uuid = require "uuid"
for i = 1, 1000000 do
  assert(uuid() ~= uuid())
end

runs in about 1 to 2 seconds faster with caching of the globals on an i7 Macbook 2013 with LuaJIT 2.0.4. Sample from the tests:

# without cached globals
$ time lua test.lua
lua test.lua  8.93s user 0.02s system 99% cpu 8.964 total
# with cached globals
$ time lua test.lua
lua test.lua  7.86s user 0.02s system 99% cpu 7.906 total

Would you accept a PR with those globals cached?

Tieske commented 8 years ago

Would you accept a PR with those globals cached?

Sure!