Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
thibaultcha
lua-resty-jit-uuid
提交
b8bd744d
L
lua-resty-jit-uuid
项目概览
镜像
/
thibaultcha
/
lua-resty-jit-uuid
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
lua-resty-jit-uuid
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
b8bd744d
编写于
3月 24, 2016
作者:
T
Thibault Charbonnier
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
docs(readme) add validation benchmarks
上级
b96889a3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
60 addition
and
16 deletion
+60
-16
README.md
README.md
+10
-8
bench.lua
bench.lua
+50
-8
未找到文件。
README.md
浏览文件 @
b8bd744d
...
...
@@ -100,11 +100,16 @@ of dependencies.
Run
`make bench`
to run them:
```
LuaJIT 2.1.0-beta1
1e+06 uuids generated
1. FFI binding took: 0.103862s
2. C binding took: 0.224119s
3. Pure LuaJIT took: 0.792812s
4. Pure Lua took: 2.139352s
UUID generation (1e+06 UUIDs)
1. FFI binding took: 0.089645s
2. C binding took: 0.233015s
3. Pure LuaJIT took: 0.719925s
4. Pure Lua took: 2.045098s
UUID validation if provided (1e+06 UUIDs)
1. Pure LuaJIT (JIT PCRE enabled) took: 0.280195s
2. FFI binding took: 0.438504s
3. Pure LuaJIT (Lua patterns) took: 0.749306s
```
*
FFI binding:
<https://github.com/bungle/lua-resty-uuid>
...
...
@@ -112,9 +117,6 @@ LuaJIT 2.1.0-beta1
*
Pure Lua:
<https://github.com/Tieske/uuid>
*
Pure LuaJIT: this module
Note: uuid validation is not benchmarked yet (all of those modules do not
necessarily provide a way to validate uuids).
[
Back to TOC
](
#table-of-contents
)
### License
...
...
bench.lua
浏览文件 @
b8bd744d
...
...
@@ -4,22 +4,25 @@ end
package.path
=
"lib/?.lua;"
..
package.path
--local luuid = require "luuid"
local
cuuid
=
require
"lua_uuid"
-- C binding
local
lua_uuid
=
require
"uuid"
-- pure Lua
local
ffi_uuid
=
require
"resty.uuid"
-- FFI binding
local
luajit_uuid
=
require
"resty.jit-uuid"
-- Pure LuaJIT
local
cuuid
=
require
"lua_uuid"
local
lua_uuid
=
require
"uuid"
local
ffi_uuid
=
require
"resty.uuid"
local
luajit_uuid
=
require
"resty.jit-uuid"
local
assert
=
assert
math.randomseed
(
os.time
())
-------------
-- Generation
-------------
local
res
=
{}
local
uuids
=
{}
local
n_uuids
=
10
^
6
local
tests
=
{
[
"Pure Lua"
]
=
lua_uuid
.
new
,
[
"Pure LuaJIT"
]
=
luajit_uuid
.
generate
,
--luuid = luuid.new,
[
"C binding"
]
=
cuuid
,
[
"FFI binding"
]
=
ffi_uuid
.
generate
[
"FFI binding"
]
=
ffi_uuid
.
generate
_random
}
for
k
,
uuid
in
pairs
(
tests
)
do
...
...
@@ -33,7 +36,46 @@ end
table.sort
(
res
,
function
(
a
,
b
)
return
a
.
time
<
b
.
time
end
)
print
(
jit
.
version
)
print
(
string.format
(
"%g uuids generated"
,
n_uuids
))
print
(
string.format
(
"UUID generation (%g UUIDs)"
,
n_uuids
))
for
i
,
result
in
ipairs
(
res
)
do
print
(
string.format
(
"%d. %s\ttook:\t%fs"
,
i
,
result
.
module
,
result
.
time
))
end
-------------
-- Validation
-------------
if
ngx
then
-- running in resty-cli
package.loaded
[
"resty.jit-uuid"
]
=
nil
ngx
.
config
.
nginx_configure
=
function
()
return
""
end
local
pattern_uuid
=
require
"resty.jit-uuid"
tests
=
{
[
"FFI binding"
]
=
ffi_uuid
.
is_valid
,
[
"Pure LuaJIT (JIT PCRE enabled)"
]
=
luajit_uuid
.
is_valid
,
[
"Pure LuaJIT (Lua patterns)"
]
=
pattern_uuid
.
is_valid
}
else
tests
=
{
[
"FFI binding"
]
=
ffi_uuid
.
is_valid
,
[
"Pure LuaJIT (Lua patterns)"
]
=
luajit_uuid
.
is_valid
}
end
res
=
{}
for
i
=
1
,
n_uuids
do
uuids
[
i
]
=
luajit_uuid
()
-- we need v4 uuids to validate with our module
end
for
k
,
validate
in
pairs
(
tests
)
do
local
tstart
=
os.clock
()
for
i
=
1
,
n_uuids
do
assert
(
validate
(
uuids
[
i
]))
end
res
[
#
res
+
1
]
=
{
module
=
k
,
time
=
os.clock
()
-
tstart
}
end
table.sort
(
res
,
function
(
a
,
b
)
return
a
.
time
<
b
.
time
end
)
print
(
string.format
(
"
\n
UUID validation if provided (%g UUIDs)"
,
n_uuids
))
for
i
,
result
in
ipairs
(
res
)
do
print
(
string.format
(
"%d. %s\ttook:\t%fs"
,
i
,
result
.
module
,
result
.
time
))
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录