Skip to content

Commit

Permalink
performance harness
Browse files Browse the repository at this point in the history
  • Loading branch information
rubyredrick committed Jun 5, 2009
1 parent 3a914a7 commit 9724c17
Show file tree
Hide file tree
Showing 14 changed files with 500,838 additions and 71 deletions.
35 changes: 14 additions & 21 deletions profiling/profile1.rb → performance/paris_eastern/subject.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib ri_cal]))
require 'rubygems'

cals = RiCal.parse_string <<-END_OF_DATA
class Subject
def initialize(out=STDOUT)
cals = RiCal.parse_string <<-END_OF_DATA
BEGIN:VCALENDAR
METHOD:PUBLISH
X-WR-TIMEZONE:America/New_York
Expand Down Expand Up @@ -78,20 +77,14 @@
END:VCALENDAR
END_OF_DATA

cal = cals.first
event = cal.events.find {|event| event.summary == "Paris Event"}
date_time = event.dtstart_property
require 'ruby-prof'
result = RubyProf.profile do
date_time.in_time_zone("US/Eastern")
end

printer = RubyProf::GraphHtmlPrinter.new(result)
profile_file = File.expand_path(File.join(File.dirname(__FILE__), %w[.. profiles profile1.html]))
File.open(profile_file, "w") do |pf|
printer.print(pf)
end

system("open #{profile_file}")
printer = RubyProf::FlatPrinter.new(result)
printer.print(STDOUT, 0)
cal = cals.first
event = cal.events.find {|event| event.summary == "Paris Event"}
@date_time = event.dtstart_property
end

def run
puts "start"
@date_time.in_time_zone("US/Eastern")
puts "done"
end
end
15 changes: 15 additions & 0 deletions performance/penultimate_weekday/subject.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'tzinfo'


class Subject
def initialize(out=STDOUT)
@event = RiCal.Event do |e|
e.dtstart = "TZID=America/New_York:19970929T090000"
e.rrule = "FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-2"
end
end

def run
@event.occurrences(:count => 7)
end
end
File renamed without changes.
16 changes: 16 additions & 0 deletions performance/psm_big_enum/subject.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Subject
def initialize(out=STDOUT)
calendar_file = File.open(File.join(File.dirname(__FILE__), *%w[ical.ics]), 'r')
@calendar = RiCal.parse(calendar_file).first
@cutoff = Date.parse("20100531")
@out = out
end
def run
cutoff = @cutoff
@calendar.events.each do |event|
event.occurrences(:before => cutoff).each do |instance|
@out.puts "Event #{instance.uid.slice(0..5)}, starting #{instance.dtstart}, ending #{instance.dtend}"
end
end
end
end
28 changes: 9 additions & 19 deletions profiling/profile2.rb → performance/utah_cycling/subject.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib ri_cal]))
require 'rubygems'

cals = RiCal.parse_string <<-ENDCAL
class Subject
def initialize(out=STDOUT)
cals = RiCal.parse_string <<-ENDCAL
BEGIN:VCALENDAR
METHOD:PUBLISH
PRODID:-//Apple Inc.//iCal 3.0//EN
Expand Down Expand Up @@ -47,19 +46,10 @@
END:VEVENT
END:VCALENDAR
ENDCAL
event = cals.first.events.first

require 'ruby-prof'
result = RubyProf.profile do
event.occurrences
end

printer = RubyProf::GraphHtmlPrinter.new(result)
profile_file = File.expand_path(File.join(File.dirname(__FILE__), %w[.. profiles profile2.html]))
File.open(profile_file, "w") do |pf|
printer.print(pf)
end
@event = cals.first.events.first
end

# system("open #{profile_file}")
printer = RubyProf::FlatPrinter.new(result)
printer.print(STDOUT, 0)
def run
@event.occurrences
end
end
36 changes: 36 additions & 0 deletions performance_data/benchmarks.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Rehearsal ------------------------------------------------------------
Benchmark paris_eastern: start
done
0.510000 0.000000 0.510000 ( 0.523553)
--------------------------------------------------- total: 0.510000sec

user system total real
Benchmark paris_eastern: start
done
0.000000 0.000000 0.000000 ( 0.001200)


Rehearsal ------------------------------------------------------------------
Benchmark penultimate_weekday: 0.330000 0.010000 0.340000 ( 0.345082)
--------------------------------------------------------- total: 0.340000sec

user system total real
Benchmark penultimate_weekday: 0.310000 0.000000 0.310000 ( 0.307988)


Rehearsal -----------------------------------------------------------
Benchmark psm_big_enum: 7.300000 0.060000 7.360000 ( 7.415546)
-------------------------------------------------- total: 7.360000sec

user system total real
Benchmark psm_big_enum: 6.570000 0.050000 6.620000 ( 6.668513)


Rehearsal -----------------------------------------------------------
Benchmark utah_cycling: 0.120000 0.000000 0.120000 ( 0.119998)
-------------------------------------------------- total: 0.120000sec

user system total real
Benchmark utah_cycling: 0.040000 0.000000 0.040000 ( 0.038606)


Loading

0 comments on commit 9724c17

Please sign in to comment.