lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I've updated my silly serialization benchmark (attached). Lua-Marshal is fast enough to be considered (by me) a viable alternative to my luabins for cases when I'd need to serialize cyclic tables and functions. (I never really needed to serialize them though.)

BTW, I remember that Fabien wanted to serialize such stuff for Metalua.

Engram is too slow to be considered even marginally useful. Serialization to Lua source is much faster (and more secure).

git clone https://github.com/agladysh/luamarca

$ ./run_benchmark.sh benchmark.lua 1e5

lua
-------------------------------------------------------------------
                name |     rel | abs s / iter = us (1e-6 s) / iter
-------------------------------------------------------------------
        luabins_load |  1.0000 |   0.57 /     100000 = 5.700000 us
        luabins_save |  1.1404 |   0.65 /     100000 = 6.500000 us
             marshal |  1.1754 |   0.67 /     100000 = 6.700000 us
           unmarshal |  1.7193 |   0.98 /     100000 = 9.800000 us
            unengram |  2.0000 |   1.14 /     100000 = 11.400000 us
          loadstring |  3.2807 |   1.87 /     100000 = 18.700000 us
              concat |  9.1754 |   5.23 /     100000 = 52.300000 us
                tstr | 12.2982 |   7.01 /     100000 = 70.100000 us
          tserialize | 17.0351 |   9.71 /     100000 = 97.100000 us
              engram | 38.3860 |  21.88 /     100000 = 218.800000 us

The full benchmark below was run with bench.engram/unengram commented out.

$ ./run_benchmark.sh benchmark.lua 1e6

lua
-------------------------------------------------------------------
                name |     rel | abs s / iter = us (1e-6 s) / iter
-------------------------------------------------------------------
        luabins_load |  1.0000 |   5.68 /    1000000 = 5.680000 us
        luabins_save |  1.1479 |   6.52 /    1000000 = 6.520000 us
             marshal |  1.1954 |   6.79 /    1000000 = 6.790000 us
           unmarshal |  1.5581 |   8.85 /    1000000 = 8.850000 us
          loadstring |  3.3151 |  18.83 /    1000000 = 18.830000 us
              concat |  9.4401 |  53.62 /    1000000 = 53.620000 us
                tstr | 12.3644 |  70.23 /    1000000 = 70.230000 us
          tserialize | 16.6021 |  94.30 /    1000000 = 94.300000 us

Modern LJ2 seems to be too smart for my benchmark (or I did break something), so no results for LJ2 this time.

Alexander.

P.S. Disclaimer: read benchmark code, run it on your own box, write your own benchmark — this one is a toy. But if you'd see a way to improve something, please tell me.

Attachment: benchmark.lua
Description: Binary data