Skip to content

Instantly share code, notes, and snippets.

@ajsharp
Created September 9, 2011 18:53
Show Gist options
  • Select an option

  • Save ajsharp/1207025 to your computer and use it in GitHub Desktop.

Select an option

Save ajsharp/1207025 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
output = `ruby -r bench_press ./benchmark.rb`
results = File.open(File.expand_path(File.dirname(__FILE__)) + "/results.txt", "a") do |f|
f.puts "\n"
f.puts "=" * 80
f.puts "Spec run time: #{Time.now}"
f.puts "Git SHA: #{`cat ../.git/\`cat ../.git/HEAD | awk '{print $2}'\``.chomp}"
f.puts output
end
require 'benchmark'
require File.expand_path(File.dirname(__FILE__) + '/../lib/bldr')
class Person
attr_reader :name
def initialize(name)
@name = name
end
end
Benchmark.bm(20) do |bm|
i = 1000
$guy = Person.new "john"
$friends = [Person.new("jim"), Person.new("bob")]
puts "i = #{i}"
bm.report "node with collection" do
i.times do
Bldr::Node.new do
object :dude => $guy do
attributes :name
collection :friends => $friends do
attributes :name
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment