[Tarantool-patches] [PATCH v1 luajit 15/41] perf: adjust md5 in LuaJIT-benches
Sergey Bronnikov
sergeyb at tarantool.org
Mon Nov 17 16:26:19 MSK 2025
Hi, Sergey,
thanks for the patch! See my comments.
Sergey
On 10/24/25 13:50, Sergey Kaplun wrote:
> This patch adjusts the aforementioned test to use the benchmark
> framework introduced before. The default arguments are adjusted
> according to the <PARAM_x86.txt> file. The arguments to the script still
> can be provided in the command line run.
> ---
> perf/LuaJIT-benches/md5.lua | 27 ++++++++++++++++++++-------
> 1 file changed, 20 insertions(+), 7 deletions(-)
>
> diff --git a/perf/LuaJIT-benches/md5.lua b/perf/LuaJIT-benches/md5.lua
> index fdf6b4a7..5ec67527 100644
> --- a/perf/LuaJIT-benches/md5.lua
> +++ b/perf/LuaJIT-benches/md5.lua
> @@ -1,5 +1,6 @@
> -
> local bit = require("bit")
> +local bench = require("bench").new(arg)
> +
> local tobit, tohex, bnot = bit.tobit or bit.cast, bit.tohex, bit.bnot
> local bor, band, bxor = bit.bor, bit.band, bit.bxor
> local lshift, rshift, rol, bswap = bit.lshift, bit.rshift, bit.rol, bit.bswap
> @@ -147,7 +148,7 @@ assert(md5('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') ==
> assert(md5('12345678901234567890123456789012345678901234567890123456789012345678901234567890') ==
> '57edf4a22be3c955ac49da2e2107b67a')
>
> -local N = tonumber(arg and arg[1]) or 10000
> +local N = tonumber(arg and arg[1]) or 20000
this deserves a comment, why 20000 instead 10000?
>
> -- Credits: William Shakespeare, Romeo and Juliet
> local txt = [[Rebellious subjects, enemies to peace,
> @@ -176,8 +177,20 @@ Once more, on pain of death, all men depart.]]
> txt = txt..txt..txt..txt
> txt = txt..txt..txt..txt
>
> -for i=1,N do
> - res = md5(txt)
> -end
> -assert(res == 'a831e91e0f70eddcb70dc61c6f82f6cd')
> -
> +bench:add({
> + name = 'md5',
> + payload = function()
> + local res
> + for i=1,N do
s/1,/1, /
> + res = md5(txt)
> + end
> + return res
> + end,
> + checker = function(res)
> + assert(res == 'a831e91e0f70eddcb70dc61c6f82f6cd')
> + return true
> + end,
> + items = N,
> +})
> +
> +bench:run_and_report()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.tarantool.org/pipermail/tarantool-patches/attachments/20251117/602a41f4/attachment.htm>
More information about the Tarantool-patches
mailing list