Skip to content

Commit

Permalink
Add benchmark for parser object
Browse files Browse the repository at this point in the history
Close #141

Co-authored-by: Hiroshi SHIBATA <[email protected]>
  • Loading branch information
dentarg and hsbt committed Sep 3, 2024
1 parent 72aaf61 commit 2302dbc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions mustermann/bench/uri_parser_object.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require "objspace"
require "uri"
require_relative "../lib/mustermann/ast/translator"

translator = Mustermann::AST::Translator.new
translator.escape("foo")

h1 = ObjectSpace.each_object.inject(Hash.new 0) { |h, o| h[o.class] += 1; h }

100.times do
translator.escape("foo")
end

h2 = ObjectSpace.each_object.inject(Hash.new 0) { |h, o| h[o.class] += 1; h }

raise if (h2[URI::RFC2396_Parser] - h1[URI::RFC2396_Parser] != 0)

0 comments on commit 2302dbc

Please sign in to comment.