Skip to content

Instantly share code, notes, and snippets.

@funny-falcon
Last active May 4, 2016 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save funny-falcon/685dbfaea16b5919e6c84ab1b156d2f6 to your computer and use it in GitHub Desktop.
Save funny-falcon/685dbfaea16b5919e6c84ab1b156d2f6 to your computer and use it in GitHub Desktop.
Test patched luajit
# unpatched
$ for i in {1..6} ; do time src/luajit test_str.lua $i ; done
1 1000000 8191
real 0m0.197s
user 0m0.196s
sys 0m0.000s
2 500000 8191
real 0m0.169s
user 0m0.164s
sys 0m0.000s
3 100000 8191
real 0m0.677s
user 0m0.664s
sys 0m0.012s
4 10000 8191
real 0m2.997s
user 0m2.992s
sys 0m0.000s
5 10000 8191
real 0m5.133s
user 0m5.124s
sys 0m0.000s
6 300000 8191
real 0m0.163s
user 0m0.160s
sys 0m0.000s
# patched
$ for i in {1..6} ; do time src/luajit test_str.lua $i ; done
1 1000000 8191
real 0m0.197s
user 0m0.192s
sys 0m0.000s
2 500000 8191
real 0m0.153s
user 0m0.152s
sys 0m0.000s
3 100000 8191
real 0m0.110s
user 0m0.102s
sys 0m0.000s
4 10000 8191
real 0m0.014s
user 0m0.012s
sys 0m0.000s
5 10000 8191
real 0m0.017s
user 0m0.016s
sys 0m0.000s
6 300000 8191
real 0m0.140s
user 0m0.136s
sys 0m0.000s
# patched with LUAJIT_SMART_STRING==2
$ for i in {1..6} ; do time src/luajit test_str.lua $i ; done
1 1000000 8191
real 0m0.199s
user 0m0.196s
sys 0m0.000s
2 500000 8191
real 0m0.155s
user 0m0.152s
sys 0m0.000s
3 100000 8191
real 0m0.131s
user 0m0.128s
sys 0m0.000s
4 10000 8191
real 0m0.020s
user 0m0.016s
sys 0m0.000s
5 10000 8191
real 0m0.025s
user 0m0.024s
sys 0m0.000s
6 300000 8191
real 0m0.143s
user 0m0.140s
sys 0m0.000s
local lng = string.rep('a',128)
local N = ...
N = N and tonumber(N) or 1
local J
local a = {}
if N == 1 then
J = 1000000
for j=1,J do
a[j%8192] = string.format("%08x", j)
end
elseif N == 2 then
J = 500000
for j=1,J do
a[j%8192] = string.format("%s%08x", lng, j)
end
elseif N == 3 then
J = 100000
for j=1,J do
a[j%8192] = string.format("%s%08x%s", lng, j, lng)
end
elseif N == 4 then
J = 10000
for j=1,J do
a[j%8192] = string.format("%s%08x%s%s", lng, j, lng, lng)
end
elseif N == 5 then
J = 10000
for j=1,J do
a[j%8192] = string.format("%s%s%08x%s", lng, lng, j, lng)
end
elseif N == 6 then
J = 300000
for j=1,J do
a[j%8192] = string.format("%s%s%s%08x", lng, lng, lng, j)
end
end
print(N, J, #a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment