Skip to content

Commit 9329a3a

Browse files
committed
Fixing generating profile report to create output dir if needed, and code change for printing report
1 parent 9df9d82 commit 9329a3a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

test/profile/helper.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
require 'ruby-prof'
33

44
class ActiveRecord::TestCase
5-
6-
5+
6+
77
protected
8-
8+
99
def ruby_profile(name)
1010
result = RubyProf.profile { yield }
1111
[:flat,:graph,:html].each do |printer|
1212
save_ruby_prof_report(result, name, printer)
1313
end
1414
end
15-
15+
1616
def save_ruby_prof_report(result, name, printer)
1717
ptr = case printer
1818
when :flat then RubyProf::FlatPrinter
@@ -21,9 +21,10 @@ def save_ruby_prof_report(result, name, printer)
2121
end
2222
file_name = printer == :html ? "#{name}_graph.html" : "#{name}_#{printer}.txt"
2323
file_path = File.join(SQLSERVER_TEST_ROOT, 'profile', 'output', file_name)
24+
Dir.mkdir(File.join(SQLSERVER_TEST_ROOT, 'profile', 'output')) unless File.exists?(File.join(SQLSERVER_TEST_ROOT, 'profile', 'output'))
2425
File.open(file_path,'w') do |file|
25-
printer == :html ? ptr.new(result).print(file) : ptr.new(result).print(file,0)
26+
printer == :html ? ptr.new(result).print(file) : ptr.new(result).print(file,{})
2627
end
2728
end
28-
29+
2930
end

0 commit comments

Comments
 (0)