Created
September 9, 2011 18:53
-
-
Save ajsharp/1207025 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/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 |
This file contains hidden or 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 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