Skip to content

Commit 50247cd

Browse files
committed
Add lunajson to benchmarks
Also made benchmarks run twice as many times.
1 parent f30fad5 commit 50247cd

File tree

2 files changed

+36
-28
lines changed

2 files changed

+36
-28
lines changed

README.md

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,35 +39,39 @@ LuaJIT 2.1.0-beta3
3939
11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
4040
4141
Running benchmarks...
42-
| Name (Decode) | Min | Max | Avg | Avg / Best |
43-
| vurv78/qjson | 0.008763 | 0.010837 | 0.00939495 | x1.72715 |
44-
| rxi/json | 0.00475 | 0.007055 | 0.00543957 | x1 |
45-
| actboy168/json | 0.010547 | 0.013259 | 0.0112183 | x2.06235 |
46-
| luadist/dkjson | 0.011222 | 0.014534 | 0.0126976 | x2.3343 |
47-
48-
| Name (Encode) | Min | Max | Avg | Avg / Best |
49-
| vurv78/qjson | 0.001677 | 0.002637 | 0.00189174 | x1 |
50-
| rxi/json | 0.010513 | 0.011322 | 0.010924 | x5.77459 |
51-
| actboy168/json | 0.009892 | 0.012293 | 0.0104864 | x5.54327 |
52-
| luadist/dkjson | 0.014829 | 0.01985 | 0.0157059 | x8.30237 |
42+
| Name (Decode) | Min | Max | Avg | Avg / Best |
43+
| vurv78/qjson | 0.008706 | 0.011876 | 0.00915391 | x1.71064 |
44+
| actboy168/json | 0.010476 | 0.013891 | 0.0113075 | x2.11309 |
45+
| luadist/dkjson | 0.011261 | 0.016459 | 0.0126863 | x2.37076 |
46+
| rxi/json | 0.004783 | 0.007264 | 0.00535117 | x1 |
47+
| grafi-tt/lunajson | 0.005398 | 0.007717 | 0.00583864 | x1.0911 |
48+
49+
| Name (Encode) | Min | Max | Avg | Avg / Best |
50+
| vurv78/qjson | 0.00166 | 0.004003 | 0.00189934 | x1 |
51+
| actboy168/json | 0.010009 | 0.012101 | 0.0107158 | x5.64188 |
52+
| luadist/dkjson | 0.014416 | 0.017742 | 0.0152628 | x8.03585 |
53+
| rxi/json | 0.010861 | 0.013424 | 0.0114725 | x6.04024 |
54+
| grafi-tt/lunajson | 0.007869 | 0.010028 | 0.00877393 | x4.61946 |
5355
```
5456

5557
```
5658
Lua 5.3
5759
11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
5860
5961
Running benchmarks...
60-
| Name (Decode) | Min | Max | Avg | Avg / Best |
61-
| luadist/dkjson | 0.028568 | 0.033705 | 0.0306484 | x1.94652 |
62-
| rxi/json | 0.045178 | 0.053548 | 0.0480421 | x3.05121 |
63-
| vurv78/qjson | 0.015006 | 0.018043 | 0.0157452 | x1 |
64-
| actboy168/json | 0.019061 | 0.023373 | 0.0200551 | x1.27372 |
65-
66-
| Name (Encode) | Min | Max | Avg | Avg / Best |
67-
| luadist/dkjson | 0.021639 | 0.024754 | 0.0226422 | x4.10556 |
68-
| rxi/json | 0.015463 | 0.019618 | 0.0166444 | x3.01802 |
69-
| vurv78/qjson | 0.005148 | 0.006336 | 0.00551502 | x1 |
70-
| actboy168/json | 0.016263 | 0.018331 | 0.0170535 | x3.09218 |
62+
| Name (Decode) | Min | Max | Avg | Avg / Best |
63+
| actboy168/json | 0.019026 | 0.023047 | 0.0202998 | x1.58917 |
64+
| rxi/json | 0.045717 | 0.05649 | 0.048758 | x3.81701 |
65+
| luadist/dkjson | 0.02851 | 0.038804 | 0.0317486 | x2.48544 |
66+
| vurv78/qjson | 0.014956 | 0.019906 | 0.0165542 | x1.29595 |
67+
| grafi-tt/lunajson | 0.011663 | 0.015941 | 0.0127739 | x1 |
68+
69+
| Name (Encode) | Min | Max | Avg | Avg / Best |
70+
| actboy168/json | 0.016101 | 0.029937 | 0.0171029 | x3.06483 |
71+
| rxi/json | 0.015395 | 0.019102 | 0.0168397 | x3.01765 |
72+
| luadist/dkjson | 0.02162 | 0.025159 | 0.0226016 | x4.05019 |
73+
| vurv78/qjson | 0.005168 | 0.0067 | 0.00558039 | x1 |
74+
| grafi-tt/lunajson | 0.011286 | 0.016953 | 0.0124624 | x2.23325 |
7175
```
7276

7377
From here, you can see this library is significantly faster for `json.encode` in comparison to `json.decode`.

benchmarks/bench.lua

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ local LIBS --[[@type table<string, table>]] = {
4646
["rxi/json"] = loadstring(get("https://raw.githubusercontent.com/rxi/json.lua/master/json.lua"))(),
4747
["actboy168/json"] = loadstring(get("https://raw.githubusercontent.com/actboy168/json.lua/master/json.lua"))(),
4848
["luadist/dkjson"] = loadstring(get("https://raw.githubusercontent.com/LuaDist/dkjson/master/dkjson.lua"))(),
49+
["grafi-tt/lunajson"] = {
50+
encode = loadstring(get("https://raw.githubusercontent.com/grafi-tt/lunajson/master/src/lunajson/encoder.lua"))()(),
51+
decode = loadstring(get("https://raw.githubusercontent.com/grafi-tt/lunajson/master/src/lunajson/decoder.lua"))()()
52+
}
4953
}
5054

5155
local DECODE_TARGET = get("https://raw.githubusercontent.com/simdjson/simdjson/master/jsonexamples/twitter.json")
@@ -62,7 +66,7 @@ do
6266
local total --[=[@type table<string, BenchResult>]=] = {}
6367
for name, lib in pairs(LIBS) do
6468
local decode = lib.decode
65-
total[name] = bench(100, function()
69+
total[name] = bench(200, function()
6670
decode(DECODE_TARGET)
6771
end)
6872
end
@@ -74,9 +78,9 @@ do
7478
end
7579
end
7680

77-
print( ("| %-15s | %-10s | %-10s | %-10s | %-11s |"):format("Name (Decode)", "Min", "Max", "Avg", "Avg / Best") )
81+
print( ("| %-20s | %-10s | %-10s | %-10s | %-11s |"):format("Name (Decode)", "Min", "Max", "Avg", "Avg / Best") )
7882
for name, result in pairs(total) do
79-
print( ("| %-15s | %-10g | %-10g | %-10g | x%-10g |"):format(name, result.min, result.max, result.avg, result.avg / best) )
83+
print( ("| %-20s | %-10g | %-10g | %-10g | x%-10g |"):format(name, result.min, result.max, result.avg, result.avg / best) )
8084
end
8185
end
8286

@@ -86,7 +90,7 @@ do
8690
local total --[=[@type table<string, BenchResult>]=] = {}
8791
for name, lib in pairs(LIBS) do
8892
local encode = lib.encode
89-
total[name] = bench(100, function()
93+
total[name] = bench(200, function()
9094
encode(ENCODE_TARGET)
9195
end)
9296
end
@@ -98,8 +102,8 @@ do
98102
end
99103
end
100104

101-
print( ("| %-15s | %-10s | %-10s | %-10s | %-11s |"):format("Name (Encode)", "Min", "Max", "Avg", "Avg / Best") )
105+
print( ("| %-20s | %-10s | %-10s | %-10s | %-11s |"):format("Name (Encode)", "Min", "Max", "Avg", "Avg / Best") )
102106
for name, result in pairs(total) do
103-
print( ("| %-15s | %-10g | %-10g | %-10g | x%-10g |"):format(name, result.min, result.max, result.avg, result.avg / best) )
107+
print( ("| %-20s | %-10g | %-10g | %-10g | x%-10g |"):format(name, result.min, result.max, result.avg, result.avg / best) )
104108
end
105109
end

0 commit comments

Comments
 (0)