doddoreul / google-code-prettify

Automatically exported from code.google.com/p/google-code-prettify
Apache License 2.0
0 stars 0 forks source link

Performance bug with newline replacement on IE 6-7 (patch included) #102

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I noticed that on extremely large files - say, 3000 lines of code inside a 
single <code> tag - IE 6 and 7 spend the vast majority of rendering time 
replacing <br>s with \r\n after the rest of the markup has occurred. By 
choosing the appropriate newline style inside recombineTagsAndDecoration, we 
can eliminate the replacement step at the end.

I've attached a patch that implements this. On the aforementioned 3kloc test 
file, it reduces IE7 rendering time on my computer from 40s to 10s, with 
similar results for IE6.

Original issue reported on code.google.com by jacobly@google.com on 10 Dec 2009 at 7:52

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks so much for profiling.  It's really hard for me to run one since I can 
only run 
IE under VMWare which is a royal PITA.

I'll try incorporating this when I get a chance.  Do you know where time under 
IE8 is 
spent?

Original comment by mikesamuel@gmail.com on 10 Dec 2009 at 8:31

GoogleCodeExporter commented 8 years ago
I just found out that IE 8 has an actual profiler, a pretty good one. I 
actually didn't 
realize earlier that this issue affected IE 8 as well, but it does.

With the patch to prettify.js, the time spent is actually fairly 
well-distributed (without 
it, there's an extra 24 seconds inside replaceWithPrettyPrintedHtml). Out of a 
total of 
1400ms, the largest contributor was emitTextUpTo at 750ms (including its 
callees in 
the time spent). This function was called 25000 times, so that's not too bad. I 
was 
actually very impressed with how fast IE 8 is on this page. In all of these 
cases, the 
total time spent in a function exceeded the time spent in its callees and in 
its own 
body, meaning that a large body of time is spent in IE itself, doing rendering.

I've attached a csv file exported from the profiler.

Original comment by jacobly@google.com on 10 Dec 2009 at 9:27

Attachments:

GoogleCodeExporter commented 8 years ago
Patched in at revision 95.  Thanks much.

Original comment by mikesamuel@gmail.com on 10 Dec 2009 at 11:25