Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up HTML encoder for 1.2 #153

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

Speed up HTML encoder for 1.2 #153

wants to merge 19 commits into from

Conversation

korny
Copy link
Member

@korny korny commented Aug 31, 2013

  • create less objects during setup
  • cache most recent 100 escaped strings
  • don't extend output unless necessary
  • lazy CSS loading and parsing

Quick benchmarking yields a ~10% speedup for Ruby code:

2.3.0@coderay ~/ruby/coderay:master rake bench
/Users/murphy/.rvm/rubies/ruby-2.3.0/bin/ruby bench/bench.rb ruby html 3000
encoding 3000 kB of ruby code to html...
run 1:  1.69 s, 1774 kB/s
run 2:  1.67 s, 1794 kB/s
run 3:  1.68 s, 1786 kB/s
run 4:  1.66 s, 1805 kB/s
run 5:  1.69 s, 1775 kB/s

2.3.0@coderay ~/ruby/coderay:possible-speedups rake bench
/Users/murphy/.rvm/rubies/ruby-2.3.0/bin/ruby bench/bench.rb ruby html 3000
encoding 3000 kB of ruby code to html...
run 1:  1.49 s, 2010 kB/s
run 2:  1.49 s, 2011 kB/s
run 3:  1.49 s, 2014 kB/s
run 4:  1.50 s, 1994 kB/s
run 5:  1.49 s, 2017 kB/s

@ghost ghost assigned korny Aug 31, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant