Skip to content

Instantly share code, notes, and snippets.

@jamescook
Created April 11, 2016 23:49
Show Gist options
  • Save jamescook/eb215e584b85f66b244a21c8a114acca to your computer and use it in GitHub Desktop.
Save jamescook/eb215e584b85f66b244a21c8a114acca to your computer and use it in GitHub Desktop.
require "benchmark/ips"
$LOAD_PATH.push File.expand_path("./lib")
require_relative "./lib/arbre.rb"
if ENV['SECOND_RUN']
class ::Arbre::Context < ::Arbre::Element
def initialize(assigns = nil, helpers = nil, &block)
assigns = (assigns || {}).symbolize_keys!
@_assigns = assigns
@_helpers = helpers
@_current_arbre_element_buffer = [self]
super(self)
instance_eval &block if block_given?
end
end
end
Benchmark.ips do |x|
x.hold! "filename"
x.time = 5
x.warmup = 2
x.report("context w/ symbolize_keys") { Arbre::Context.new(x: "y", y: "x") }
x.report("context w/ symbolize_keys!") { Arbre::Context.new(x: "y", y: "x") }
x.compare!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment