awfy 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/awfy/cli.rb +77 -70
- data/lib/awfy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f90af1a6ce12d7b811d3fb6353f91d46e1637607b7890d3ed0837fbeda7fdd96
|
4
|
+
data.tar.gz: e2a17a61c3ecf4d5795fc636407b49fa1aeaf150308f67215acf8d648d8f5df5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22291837342e69a9da6c55e7a4a6869a80b2dfa47d67e2ad3847a870335999560109de557f73b58d1b73d564fb1f9f016654fcc542ecada0238b16276a74ca23
|
7
|
+
data.tar.gz: 4c8dfa85d87b246512f7a478bfdf844c4af7361e1b6d87a418bf1d96aaa260a592194f3c7114f79cdfb38afc3a473da871f52f93c2f20811739bdbe05ba2bf77
|
data/lib/awfy/cli.rb
CHANGED
@@ -25,7 +25,6 @@ module Awfy
|
|
25
25
|
|
26
26
|
class_option :summary, type: :boolean, desc: "Generate a summary of the results", default: true
|
27
27
|
class_option :verbose, type: :boolean, desc: "Verbose output", default: false
|
28
|
-
class_option :quiet, type: :boolean, desc: "Silence output", default: false
|
29
28
|
|
30
29
|
class_option :ips_warmup, type: :numeric, default: 1, desc: "Number of seconds to warmup the benchmark"
|
31
30
|
class_option :ips_time, type: :numeric, default: 3, desc: "Number of seconds to run the benchmark"
|
@@ -48,33 +47,34 @@ module Awfy
|
|
48
47
|
|
49
48
|
run_pref_test(group) { run_ips(_1, report, test) }
|
50
49
|
end
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
50
|
+
|
51
|
+
desc "memory [GROUP] [REPORT] [TEST]", "Run memory profiling"
|
52
|
+
def memory(group = nil, report = nil, test = nil)
|
53
|
+
say "Running memory profiling for:"
|
54
|
+
say "> #{requested_tests(group, report, test)}..."
|
55
|
+
|
56
|
+
run_pref_test(group) { run_memory(_1, report, test) }
|
57
|
+
end
|
58
|
+
|
59
|
+
desc "flamegraph GROUP REPORT TEST", "Run flamegraph profiling"
|
60
|
+
def flamegraph(group, report, test)
|
61
|
+
say "Creating flamegraph for:"
|
62
|
+
say "> #{[group, report, test].join("/")}..."
|
63
|
+
|
64
|
+
configure_benchmark_run
|
65
|
+
run_group(group) { run_flamegraph(_1, report, test) }
|
66
|
+
end
|
67
|
+
|
68
68
|
# # TODO: also YJIT stats output?
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
69
|
+
desc "profile [GROUP] [REPORT] [TEST]", "Run CPU profiling"
|
70
|
+
option :iterations, type: :numeric, default: 1_000_000, desc: "Number of iterations to run the test"
|
71
|
+
def profile(group = nil, report = nil, test = nil)
|
72
|
+
say "Run profiling of:"
|
73
|
+
say "> #{requested_tests(group, report, test)}..."
|
74
|
+
|
75
|
+
configure_benchmark_run
|
76
|
+
run_group(group) { run_profiling(_1, report, test) }
|
77
|
+
end
|
78
78
|
|
79
79
|
private
|
80
80
|
|
@@ -147,7 +147,7 @@ module Awfy
|
|
147
147
|
prepare_output_directory_for_ips
|
148
148
|
|
149
149
|
execute_report(group, report_name) do |report, runtime|
|
150
|
-
Benchmark.ips(time: options[:ips_time], warmup: options[:ips_warmup], quiet:
|
150
|
+
Benchmark.ips(time: options[:ips_time], warmup: options[:ips_warmup], quiet: show_summary? || verbose?) do |bm|
|
151
151
|
execute_tests(report, test_name, output: false) do |test, _|
|
152
152
|
test_label = "[#{runtime}] #{test[:control] ? CONTROL_MARKER : TEST_MARKER} #{test[:name]}"
|
153
153
|
bm.item(test_label, &test[:block])
|
@@ -158,50 +158,56 @@ module Awfy
|
|
158
158
|
bm.save!(file_name)
|
159
159
|
end
|
160
160
|
|
161
|
-
bm.compare! if verbose?
|
161
|
+
bm.compare! if verbose? || !show_summary?
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
165
165
|
generate_ips_summary if options[:summary]
|
166
166
|
end
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
167
|
+
|
168
|
+
def run_memory(group, report_name, test_name)
|
169
|
+
if verbose?
|
170
|
+
say "> Memory profiling for:"
|
171
|
+
say "> #{group[:name]}...", :cyan
|
172
|
+
end
|
173
|
+
execute_report(group, report_name) do |report, runtime|
|
174
|
+
execute_tests(report, test_name) do |test, _|
|
175
|
+
MemoryProfiler.report do
|
176
|
+
test[:block].call
|
177
|
+
end.pretty_print
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
def run_flamegraph(group, report_name, test_name)
|
183
|
+
execute_report(group, report_name) do |report, runtime|
|
184
|
+
execute_tests(report, test_name) do |test, _|
|
185
|
+
label = "report-#{group[:name]}-#{report[:name]}-#{test[:name]}".gsub(/[^A-Za-z0-9_\-]/, "_")
|
186
|
+
generate_flamegraph(label) do
|
187
|
+
test[:block].call
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def run_profiling(group, report_name, test_name)
|
194
|
+
if verbose?
|
195
|
+
say "> Profiling for:"
|
196
|
+
say "> #{group[:name]} (iterations: #{options[:iterations]})...", :cyan
|
197
|
+
end
|
198
|
+
execute_report(group, report_name) do |report, runtime|
|
199
|
+
execute_tests(report, test_name) do |test, iterations|
|
200
|
+
data = StackProf.run(mode: :cpu, interval: 100) do
|
201
|
+
i = 0
|
202
|
+
while i < iterations
|
203
|
+
test[:block].call
|
204
|
+
i += 1
|
205
|
+
end
|
206
|
+
end
|
207
|
+
StackProf::Report.new(data).print_text
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
205
211
|
|
206
212
|
def execute_report(group, report_name, &)
|
207
213
|
runtime = options[:runtime]
|
@@ -242,7 +248,7 @@ module Awfy
|
|
242
248
|
|
243
249
|
say if verbose?
|
244
250
|
say "> --------------------------" if verbose?
|
245
|
-
say "> Report (#{runtime} - branch '#{git_current_branch_name}'): #{report[:name]}"
|
251
|
+
say "> Report (#{runtime} - branch '#{git_current_branch_name}'): #{report[:name]}", :magenta
|
246
252
|
say "> --------------------------" if verbose?
|
247
253
|
say if verbose?
|
248
254
|
yield run_report, runtime
|
@@ -403,7 +409,8 @@ module Awfy
|
|
403
409
|
ensure
|
404
410
|
say "Switching back to branch '#{previous_branch}'" if verbose?
|
405
411
|
git_client.checkout(previous_branch)
|
406
|
-
|
412
|
+
# Git client does not have a pop method so send our own command
|
413
|
+
git_client.lib.send(:command, "stash", "pop")
|
407
414
|
end
|
408
415
|
|
409
416
|
def git_current_branch_name = git_client.current_branch
|
@@ -416,6 +423,6 @@ module Awfy
|
|
416
423
|
|
417
424
|
def verbose? = options[:verbose]
|
418
425
|
|
419
|
-
def
|
426
|
+
def show_summary? = options[:summary]
|
420
427
|
end
|
421
428
|
end
|
data/lib/awfy/version.rb
CHANGED