public
Description: Fork of DataMapper 0.3 with patches to fix major show-stopping bugs
Clone URL: git://github.com/cardmagic/dm-works.git
Search Repo:
dm-works / profile_data_mapper.rb
100644 40 lines (34 sloc) 0.693 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/opt/local/bin/ruby
 
require 'environment'
require 'ruby-prof'
 
# RubyProf, making profiling Ruby pretty since 1899!
def profile(&b)
  result = RubyProf.profile &b
 
  printer = RubyProf::GraphHtmlPrinter.new(result)
  File::open('profile_results.html', 'w+') do |file|
    printer.print(file, 0)
  end
end
 
profile do
  1000.times do
    Zoo.all.each { |zoo| zoo.name; zoo.exhibits.entries }
  end
end
 
puts "Done!"
 
# require 'benchmark'
#
# N = 100_000
#
# Benchmark::bmbm do |x|
# x.report do
# N.times do
# Inflector.underscore('DataMapper')
# end
# end
#
# x.report do
# N.times do
# String::memoized_underscore('DataMapper')
# end
# end
# end