Skip to content

Commit 12b015d

Browse files
committedNov 10, 2014
Profiling task
1 parent 74bbb30 commit 12b015d

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed
 

‎Rakefile

+28-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# encoding: utf-8
2-
32
require 'rubygems'
43
require 'bundler'
4+
55
begin
66
Bundler.setup(:default, :development)
77
rescue Bundler::BundlerError => e
@@ -44,7 +44,6 @@ end
4444

4545
require 'rspec/core/rake_task'
4646
RSpec::Core::RakeTask.new(:spec)
47-
4847
task :default => :spec
4948

5049
require 'rdoc/task'
@@ -56,3 +55,30 @@ Rake::RDocTask.new do |rdoc|
5655
rdoc.rdoc_files.include('README*')
5756
rdoc.rdoc_files.include('lib/**/*.rb')
5857
end
58+
59+
desc "Dump profiling data"
60+
task :profile do
61+
require 'benchmark'
62+
require 'stackprof'
63+
64+
$:.unshift File.dirname(__FILE__) + '/lib' # Make Ruby aware of load path
65+
require './lib/rubyXL'
66+
67+
spreadsheets = Dir.glob(File.join("test", "input", "*.xls?")).sort!
68+
69+
spreadsheets.each { |input|
70+
puts "<<<--- Profiling parsing #{input}..."
71+
doc = nil
72+
StackProf.run(:mode => :cpu, :interval => 100,
73+
:out => "tmp/stackprof-cpu-parse-#{File.basename(input)}.dump") {
74+
doc = RubyXL::Parser.parse(input)
75+
}
76+
77+
output = File.join("test", "output", File.basename(input))
78+
puts "--->>> Profiling writing of #{output}..."
79+
StackProf.run(:mode => :cpu, :interval => 100,
80+
:out => "tmp/stackprof-cpu-write-#{File.basename(input)}.dump") {
81+
doc.write(output)
82+
}
83+
}
84+
end

‎tmp/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.dump

0 commit comments

Comments
 (0)
Please sign in to comment.