Skip to content

Commit 254e392

Browse files
author
Charlie Savage
committed
Allocation report.
1 parent aef58ab commit 254e392

File tree

2 files changed

+1305
-5
lines changed

2 files changed

+1305
-5
lines changed

create_examples.rb

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,38 @@
1313
require prime_path
1414

1515
# Generate example reports
16-
def generate_reports(result)
16+
def generate_timing_reports
17+
start = Process.times
18+
result = RubyProf.profile do
19+
run_primes(10000)
20+
end
21+
1722
path = File.join('examples')
1823
path = File.expand_path(path)
1924
FileUtils.makedirs(path)
2025
printer = RubyProf::MultiPrinter.new(result, [:flat, :flat_with_lines, :graph, :graph_html, :call_info, :tree, :stack, :dot])
2126
printer.print(:path => path, :profile => 'primes')
2227
end
2328

24-
def run
25-
start = Process.times
26-
result = RubyProf.profile do
29+
def generate_allocation_report
30+
result = RubyProf.profile(:measure_mode => RubyProf::ALLOCATIONS, :track_allocations => true) do
2731
run_primes(10000)
2832
end
2933

30-
generate_reports(result)
34+
path = File.join('examples')
35+
path = File.expand_path(path)
36+
FileUtils.makedirs(path)
37+
38+
printer = RubyProf::GraphHtmlPrinter.new(result)
39+
path = File.join(path, 'primes.graph.allocations.html')
40+
File.open(path, 'wb') do |file|
41+
printer.print(file)
42+
end
43+
end
44+
45+
def run
46+
generate_timing_reports
47+
generate_allocation_report
3148
end
3249

3350
run

0 commit comments

Comments
 (0)