Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Slightly faster escaping for the `String` renderer #36

Closed
meiersi opened this Issue · 2 comments

2 participants

@meiersi
Collaborator

The escaping in the String renderer currently looks like

'<'  -> "&lt;"   ++ escapeHtmlEntities cs k
....

However, in my experience the slightly more ugly

'<'  -> '&':'l':'t':';':escapeHtmlEntities cs k
...

is faster. It would be great, if we could try out this change and measure the difference in performance. Obviously, this change matters most for use cases requiring a significant amount of escaping.

@jaspervdj
Owner

Implemented, benchmarked, accepted.

Before this transformation:

  • bigTable (String): 4.732035 ms (std dev: 390.9333 us)
  • basic (String): 14.66538 us (std dev: 75.75378 ns)
  • wideTree (String): 4.370032 ms (std dev: 279.0774 us)
  • wideTreeEscaping (String): 1.049168 ms (std dev: 3.031388 us)
  • deepTree (String): 2.869720 ms (std dev: 855.4002 us)
  • manyAttributes (String): 3.843686 ms (std dev: 989.2406 us)

After:

  • bigTable (String): 4.062248 ms (std dev: 339.5793 us)
  • basic (String): 13.79819 us (std dev: 76.73878 ns)
  • wideTree (String): 4.337962 ms (std dev: 37.49904 us)
  • wideTreeEscaping (String): 843.0063 us (std dev: 9.630759 us)
  • deepTree (String): 2.767646 ms (std dev: 630.6085 us)
  • manyAttributes (String): 3.689679 ms (std dev: 983.5755 us)
@meiersi
Collaborator

Great! Thanks for the good work!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.