[MacRuby-devel] String performance (yet another)

Laurent Sansonetti lsansonetti at apple.com
Sun Jan 16 19:34:58 PST 2011


Hi Yasu,

Indeed, String#[] will now perform slower on UTF8 non-ascii strings, because computing the character index cannot be done in constant time anymore.

I don't believe this can be improved using the optimization we implemented for #gsub and #scan. Maybe 1.9.2 has a better optimization, I will let Vincent comment :)

Laurent

On Jan 16, 2011, at 8:26 AM, Yasu Imao wrote:

> Hi,
> 
> I found another String performance issue, which is different from #1077.  I used the same 8092 words English text in UTF-8 used in #1077.
> 
> The latest nightly (2011/01/16) is about 6 times slower than MacRuby 0.8, which was as fast as 1.9.2.  
> 
> I'm just wondering if I should file this for 0.9 or for 'later'.
> 
> 
> text = File.read("test.txt")
> #text = File.read("test.txt").force_encoding("UTF-16BE")
> 1000.times do |i|
>  a = text[i,i+30]
> end
> 
> 
> *Ruby 1.8.7				0.0019	0.0018	0.0017
> Ruby 1.9.2				0.029	0.030	0.029
> MacRuby 0.8				0.028	0.025	0.028
> MacRuby 0.9 2011/01/16	0.18		0.17		0.18
> MacRuby 0.9 2011/01/16	0.0023	0.0029	0.0021
> (force_encoding)
> 
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20110116/33e16c4b/attachment-0001.html>


More information about the MacRuby-devel mailing list