-
Notifications
You must be signed in to change notification settings - Fork 195
/
Copy pathprofiler.rb
47 lines (38 loc) · 1.04 KB
/
profiler.rb
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
41
42
43
44
45
46
47
require_relative 'main'
require 'stackprof'
require 'ruby-prof'
require 'vernier'
require 'oj'
class Profiler
def initialize(count_lines:)
@count_lines = count_lines
end
def call
profile_by_stack_prof
profile_by_stack_prof_raw
profile_by_ruby_prof
profile_by_vernier
end
private
attr_reader :count_lines
def profile_by_stack_prof = StackProf.run(mode: :wall, out: 'profiles/stackprof.dump') do
action
end
def profile_by_stack_prof_raw
result = StackProf.run(mode: :wall, raw: true) do
action
end
File.write('profiles/stackprof.json', Oj.dump(result, mode: :compat))
end
def profile_by_ruby_prof
result = RubyProf.profile do
action
end
printer = RubyProf::MultiPrinter.new(result, [:flat, :graph, :tree, :call_tree, :stack, :graph_html])
printer.print(:path => ".", :profile => "profiles/ruby_prof_profile")
end
def profile_by_vernier = Vernier.profile(out: "profiles/time_profile.json") do
action
end
def action = Main.new(options: { count_lines: }).call
end