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

Upgrade blueprint benchmark template #16

Closed
wants to merge 1 commit into from

Conversation

stephannv
Copy link

Hey, I was working on Blueprint perf improvements today and I got improved numbers. It's not close to to_html times but at least it's something.
Two things that contributed:

  • Using String::Builder instead IO::Memory 🤦🏽
  • Allowing passing content without using blocks, eg. h1("Hello").
         ecr   3.48M (286.99ns) (± 1.11%)  4.27kB/op        fastest
     to_html   1.90M (525.41ns) (± 0.88%)  5.52kB/op   1.83× slower
   blueprint 481.79k (  2.08µs) (± 0.78%)   9.8kB/op   7.23× slower
html_builder 118.20k (  8.46µs) (± 0.85%)  10.4kB/op  29.48× slower
       water 114.23k (  8.75µs) (± 0.59%)  11.2kB/op  30.50× slower
     markout  89.04k ( 11.23µs) (± 0.74%)  15.6kB/op  39.13× slower

@stephannv
Copy link
Author

I realized why the speed improvement. I forgot to escape content passed via argument without using block 😅
After the fix (stephannv/blueprint#55), it returned to the ~9x slower level. Closing here.

@stephannv stephannv closed this Sep 9, 2024
@sbsoftware
Copy link
Owner

Too bad it didn't work out!

I'm was also considering to support providing content via arguments, but I doubt it would bring any performance benefit to to_html.cr as blocks are eliminated/flattened when compiling anyway. Do you think it is worth the effort usability-wise?

@stephannv
Copy link
Author

@sbsoftware At first I didn't like, but I started to enjoy using on situations like:

h1 "Title here"

span "More content here"

footer @my_var

It feels a little like slim/pug template languages

Ps. I worked on some improvements today and I could improve the numbers a little bit, I will open a new PR since I force pushed my branch and I can't reopen this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants