On Mon, Apr 16, 2012 at 7:47 PM, Gustavo Sverzut Barbieri <barbi...@profusion.mobi> wrote: > On Sun, Apr 15, 2012 at 2:06 AM, Daniel Fitzpatrick > <doubleagen...@gmail.com> wrote: >> In messing around with creating Clojure bindings for the EFL, I decided to >> do some performance benchmarks on the low hanging fruit. Since we're going >> through a binding layer (the JNA), I wanted something from the >> clojure-world which would help balance the scales a bit more. Since >> Clojure's split operation handles regex, making the code more complex, I >> felt that would help. I suspected these to be about even, but they were >> not what I'd suspected. >> >> ; eina_init called somewhere up here.... >> user=> (ave 1000 (vec (eina/eina_str_split >> "Calvin;Leoben;D'anna;Simon;Dora2;105Rl;Six;Daniel;Sharon" ";" 0))) >> 0.08763943600000001 >> user=> (ave 1000 (split >> "Calvin;Leoben;D'anna;Simon;Dora2;105Rl;Six;Daniel;Sharon" #";")) >> 0.008177458999999986 >> >> >> This tells it to perform the split operation 1000 times and then give the >> average number of milliseconds elapsed for each execution. Any ideas why >> eina is so much slower? > > eina_str_split() is quite naive implementation and not optimized. It > does 3 pass over the string: 1) strlen(); 2) count tokens to allocate > memory; 3) populate tokens on return value. > > The first strlen is stupid and is being used to check for empty > string... no idea why it got in. The second and third steps could be > joined using realloc and growing at an incremental step. This could > help the performance a bit. > > In the case of a max_tokens is provided, it could pre-allocate the tokens > array. > > Last but not least there are optimizations to be applied to the > character match, doing word search (8 chars on 64bits) instead of > byte... > > OTOH, it's quite space efficient for the return value, a single > allocation is done to contain it all. > > But is it really useful? Does it matter?
Well, small change like removing strlen could be done. But yes, does it really matter, I never saw that function showing up in any benchmark. In fact, that's certainly the main reason it is slow. It never did hurt anyone. So if it hurt you, then patch are welcome :-) -- Cedric BAIL ------------------------------------------------------------------------------ For Developers, A Lot Can Happen In A Second. Boundary is the first to Know...and Tell You. Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! http://p.sf.net/sfu/Boundary-d2dvs2 _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel