Permalink
Browse files

Added sample perftools script.

  • Loading branch information...
jnunemaker committed Oct 13, 2012
1 parent a4c563a commit 4bed0822c5ce8025079566c68091686a5ba6dd74
Showing with 21 additions and 0 deletions.
  1. +21 −0 script/criteria_hash.rb
View
@@ -0,0 +1,21 @@
+require 'pp'
+require 'pathname'
+require 'benchmark'
+require 'rubygems'
+require 'bundler'
+
+Bundler.require :default, :performance
+
+root_path = Pathname(__FILE__).dirname.join('..').expand_path
+lib_path = root_path.join('lib')
+$:.unshift(lib_path)
+require 'plucky'
+
+criteria = Plucky::CriteriaHash.new(:foo => 'bar')
+
+PerfTools::CpuProfiler.start("/tmp/criteria_hash") do
+ 1_000_000.times { criteria[:foo] = 'bar' }
+end
+
+puts system "pprof.rb --gif /tmp/criteria_hash > /tmp/criteria_hash.gif"
+puts system "open /tmp/criteria_hash.gif"

0 comments on commit 4bed082

Please sign in to comment.