[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaJIT string concat
- From: Francesco Abbate <francesco.bbt@...>
- Date: Thu, 14 Apr 2011 09:21:33 +0200
2011/4/13 Geoff Leyland <geoff_leyland@fastmail.fm>:
> Why not profile it? (you'll need to look at the output in a monospaced font)
>
> $ lua -luatrace.profile concat-bench.lua
> ...
>
> ==================================================================================
> Visits Total Self Child Line | concat-bench.lua - Times in milliseconds
> ----------------------------------------------------------------------------------
> 1 0.00 0.00 0.00 1 | local t = {}
> 101 0.01 0.01 0.00 2 | for i = 1, 100 do
> 100 0.25 0.25 0.00 3 | t[i] = "abc"..tostring(i)
> . . . . 4 | end
> . . . . 5 |
> . . . . 6 | local sformat, rnd, tostring, a =
> 1 0.00 0.00 0.00 7 | string.format, math.random, tostring, nil
> . . . . 8 |
> 100001 9.28 9.28 0.00 9 | for i= 1,100000 do
> 100000 648.02 648.02 0.00 10 | local s = table.concat(t, ",")
> 100000 96.93 96.93 0.00 11 | a = sformat("[%s]", s)
> . . . . 12 | end
> . . . . 13 |
> 100001 9.40 9.40 0.00 14 | for i= 1,100000 do
> 100000 644.82 644.82 0.00 15 | local s = table.concat(t, ",")
> 100000 60.55 60.55 0.00 16 | a = "["..s.."]"
> 1 0.00 0.00 0.00 17 | end
Hi all,
I see that the benchmark tell that the concatenation method is a
little bit faster. I'm a little bit surprised but it is true that for
the case with very small strings many small elements came to play to
determine the final timing and the benchmarks can contradict some
common beliefs.
My only doubt now is what happens is the string is big... I was
wondering if in this case the results can be different but may be that
I still have some wrong belief!! :-)
--
Francesco
- References:
- LuaJIT string concat, Henning Diedrich
- Re: LuaJIT string concat, Francesco Abbate
- Re: LuaJIT string concat, Alexander Gladysh
- Re: LuaJIT string concat, Francesco Abbate
- Re: LuaJIT string concat, Peter Cawley
- Re: LuaJIT string concat, Francesco Abbate
- Re: LuaJIT string concat, steve donovan
- Re: LuaJIT string concat, Henning Diedrich
- Re: LuaJIT string concat, Pierre-Yves Gérardy
- Re: LuaJIT string concat, Pierre-Yves Gérardy
- Re: LuaJIT string concat, Pierre-Yves Gérardy
- Re: LuaJIT string concat, Geoff Leyland