Last active
September 5, 2024 19:24
-
-
Save jgaskins/ba2bda6b56cb7a8702e61fd31f6738ed to your computer and use it in GitHub Desktop.
Benchmarking Phlex-like components in Armature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
➜ armature git:(master) ✗ crystal run --release bench_code_component.cr | |
name 815.75k ( 1.23µs) (± 5.66%) 336B/op fastest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "benchmark" | |
require "../src/component" | |
record NestedNameComponent < Armature::Component, name : String do | |
render do | |
3.times do | |
div(class: "users") do | |
h2 { "#{@name} message" } | |
p(id: "user-#{@name}") do | |
span(class: "title") { "they:" } | |
span(class: "message") { "nested hello #{@name}" } | |
end | |
end | |
end | |
end | |
end | |
buffer = IO::Memory.new(1 << 16) | |
Benchmark.ips do |x| | |
x.report "name" { NestedNameComponent.new(name: "Fox Mulder").to_s buffer.rewind } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment