[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Perl, Python, Ruby, PHP, C, C++, Lua, tcl, javascript and Java comparison
- From: Malma <malma@...>
- Date: Tue, 16 Jul 2013 01:17:53 +0400
I've tested this bencmark sample, and test says that a bottleneck is
string.gsub.
So, I've replaced string.gsub with my simple realization of replace
function in C.
Here modified code and results for first 5 steps:
local str='abcdefgh'..'efghefgh';
local imax=1024/#str*1024*4; -- 4mb
local starttime=os.time();
print "exec.tm.sec\tstr.length";
local gstr='';
local i=0;
while i < imax+1000 do
i=i+1;
gstr=gstr..str;
gstr=string.swap(gstr,"efgh","____");
local lngth=#str*i;
if(math.mod(lngth,1024*256)==0) then
print(os.time()-starttime.."sec\t\t"..(lngth/1024).."kb");
end
end
Timings string.swap:
2sec 256kb
11sec 512kb
27sec 768kb
49sec 1024kb
78sec 1280kb
Timings string.gsub:
29sec 256kb
118sec 512kb
275sec 768kb
Tested on Intel Core i5-2300 2.8GHz
- References:
- Perl, Python, Ruby, PHP, C, C++, Lua, tcl, javascript and Java comparison, Daniel Bolgheroni
- Re: Perl, Python, Ruby, PHP, C, C++, Lua, tcl, javascript and Java comparison, Roberto Ierusalimschy
- Re: Perl, Python, Ruby, PHP, C, C++, Lua, tcl, javascript and Java comparison, kamicc olo
- Re: Perl, Python, Ruby, PHP, C, C++, Lua, tcl, javascript and Java comparison, Henning Diedrich
- Re: Perl, Python, Ruby, PHP, C, C++, Lua, tcl, javascript and Java comparison, Laurent Faillie
- Prev by Date:
Re: Why Mobile Apps Are Slow
- Next by Date:
Re: Why Mobile Apps Are Slow
- Previous by thread:
Re: Perl, Python, Ruby, PHP, C, C++, Lua, tcl, javascript and Java comparison
- Next by thread:
Re: Perl, Python, Ruby, PHP, C, C++, Lua, tcl, javascript and Java comparison
- Index(es):