awfy 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.ruby-version +1 -0
- data/.standard.yml +3 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +10 -0
- data/exe/awfy +4 -0
- data/lib/awfy/cli.rb +421 -0
- data/lib/awfy/version.rb +5 -0
- data/lib/awfy.rb +30 -0
- data/sig/awfy.rbs +4 -0
- metadata +198 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5bea684a36c13b8593199aa4490e13c5fbdcb35222766daa401b9c8151a71c8f
|
4
|
+
data.tar.gz: 1825c25d81bd2210269d713313a8634d66f654b13e763e1f4bb33f7f62bcfe67
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 273fda35ea1688650b64b815d7b8b37b15485214341de4e2ca7e048a3f84f89cc0cb5693cadd5bfb0ed14810eb2169f142080e82df26c60acdbc1b421e046403
|
7
|
+
data.tar.gz: d00c1252bbb61fe0687806be84dcc6cdc2ce20148b893fe50f09dc82fa258ec0f6f4deb1a89aefae0efcb51c187aa3a2928db748dfa321f096b4f71b328e0465
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.3.5
|
data/.standard.yml
ADDED
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Stephen Ierodiaconou
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Awfy (Are We Fast Yet)
|
2
|
+
|
3
|
+
TODO: Delete this and the text below, and describe your gem
|
4
|
+
|
5
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/awfy`. To experiment with that code, run `bin/console` for an interactive prompt.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
10
|
+
|
11
|
+
Install the gem and add to the application's Gemfile by executing:
|
12
|
+
|
13
|
+
```bash
|
14
|
+
bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
|
15
|
+
```
|
16
|
+
|
17
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
18
|
+
|
19
|
+
```bash
|
20
|
+
gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
|
21
|
+
```
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/awfy.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/exe/awfy
ADDED
data/lib/awfy/cli.rb
ADDED
@@ -0,0 +1,421 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "fileutils"
|
4
|
+
require "thor"
|
5
|
+
require "benchmark/ips"
|
6
|
+
require "stackprof"
|
7
|
+
require "singed"
|
8
|
+
require "memory_profiler"
|
9
|
+
require "git"
|
10
|
+
require "json"
|
11
|
+
require "terminal-table"
|
12
|
+
|
13
|
+
module Awfy
|
14
|
+
class CLI < Thor
|
15
|
+
include Thor::Actions
|
16
|
+
|
17
|
+
CONTROL_MARKER = "[c]"
|
18
|
+
TEST_MARKER = "[*]"
|
19
|
+
|
20
|
+
def self.exit_on_failure? = true
|
21
|
+
|
22
|
+
class_option :runtime, enum: ["both", "yjit", "mri"], default: "both", desc: "Run with and/or without YJIT enabled"
|
23
|
+
class_option :compare_with, type: :string, desc: "Name of branch to compare with results on current branch"
|
24
|
+
class_option :compare_control, type: :boolean, desc: "When comparing branches, also re-run all control blocks too", default: false
|
25
|
+
|
26
|
+
class_option :summary, type: :boolean, desc: "Generate a summary of the results", default: true
|
27
|
+
class_option :verbose, type: :boolean, desc: "Verbose output", default: false
|
28
|
+
class_option :quiet, type: :boolean, desc: "Silence output", default: false
|
29
|
+
|
30
|
+
class_option :ips_warmup, type: :numeric, default: 1, desc: "Number of seconds to warmup the benchmark"
|
31
|
+
class_option :ips_time, type: :numeric, default: 3, desc: "Number of seconds to run the benchmark"
|
32
|
+
class_option :temp_output_directory, type: :string, default: "./benchmarks/tmp", desc: "Directory to store temporary output files"
|
33
|
+
class_option :setup_file_path, type: :string, default: "./benchmarks/setup", desc: "Path to the setup file"
|
34
|
+
class_option :tests_path, type: :string, default: "./benchmarks/tests", desc: "Path to the tests files"
|
35
|
+
|
36
|
+
# TODO: implement assert option
|
37
|
+
# class_option :assert, type: :boolean, desc: "Assert that the results are within a certain threshold coded in the tests"
|
38
|
+
|
39
|
+
desc "list [GROUP]", "List all tests in a group"
|
40
|
+
def list(group = nil)
|
41
|
+
run_pref_test(group) { list_group(_1) }
|
42
|
+
end
|
43
|
+
|
44
|
+
desc "ips [GROUP] [REPORT] [TEST]", "Run IPS benchmarks"
|
45
|
+
def ips(group = nil, report = nil, test = nil)
|
46
|
+
say "Running IPS for:"
|
47
|
+
say "> #{requested_tests(group, report, test)}..."
|
48
|
+
|
49
|
+
run_pref_test(group) { run_ips(_1, report, test) }
|
50
|
+
end
|
51
|
+
#
|
52
|
+
# desc "memory [GROUP] [REPORT] [TEST]", "Run memory profiling"
|
53
|
+
# def memory(group = nil, report = nil, test = nil)
|
54
|
+
# say "Running memory profiling for:"
|
55
|
+
# say "> #{requested_tests(group, report, test)}..."
|
56
|
+
#
|
57
|
+
# run_pref_test(group) { run_memory(_1, report, test) }
|
58
|
+
# end
|
59
|
+
#
|
60
|
+
# desc "flamegraph GROUP REPORT TEST", "Run flamegraph profiling"
|
61
|
+
# def flamegraph(group, report, test)
|
62
|
+
# say "Creating flamegraph for:"
|
63
|
+
# say "> #{[group, report, test].join("/")}..."
|
64
|
+
# configure_benchmark_run
|
65
|
+
# run_group(group) { run_flamegraph(_1, report, test) }
|
66
|
+
# end
|
67
|
+
#
|
68
|
+
# # TODO: also YJIT stats output?
|
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
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def say_configuration
|
82
|
+
return unless verbose?
|
83
|
+
say
|
84
|
+
say "| on branch '#{git_client.current_branch}', and #{options[:compare_with] ? "compare with branch: '#{options[:compare_with]}', and " : ""}Runtime: #{options[:runtime].upcase} and assertions: #{options[:assert] || "skip"}", :cyan
|
85
|
+
say
|
86
|
+
end
|
87
|
+
|
88
|
+
def configure_benchmark_run
|
89
|
+
say_configuration
|
90
|
+
|
91
|
+
Singed.output_directory = options[:temp_output_directory]
|
92
|
+
expanded_setup_file_path = File.expand_path(options[:setup_file_path], Dir.pwd)
|
93
|
+
expanded_tests_path = File.expand_path(options[:tests_path], Dir.pwd)
|
94
|
+
test_files = Dir.glob(File.join(expanded_tests_path, "*.rb"))
|
95
|
+
|
96
|
+
require expanded_setup_file_path
|
97
|
+
test_files.each { |file| require file }
|
98
|
+
end
|
99
|
+
|
100
|
+
def requested_tests(group, report = nil, test = nil)
|
101
|
+
tests = [group, report, test].compact
|
102
|
+
return "(all)" if tests.empty?
|
103
|
+
tests.join("/")
|
104
|
+
end
|
105
|
+
|
106
|
+
def run_pref_test(group, &)
|
107
|
+
configure_benchmark_run
|
108
|
+
if group
|
109
|
+
run_group(group, &)
|
110
|
+
else
|
111
|
+
run_groups(&)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def run_groups(&)
|
116
|
+
current_groups.keys.each do |group_name|
|
117
|
+
run_group(group_name, &)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def current_groups
|
122
|
+
@current_groups ||= Awfy.groups.dup.freeze
|
123
|
+
end
|
124
|
+
|
125
|
+
def run_group(group_name)
|
126
|
+
group = current_groups[group_name]
|
127
|
+
raise "Group not found" unless group
|
128
|
+
yield group
|
129
|
+
end
|
130
|
+
|
131
|
+
def list_group(group)
|
132
|
+
say "> #{group[:name]}"
|
133
|
+
group[:reports].each do |report|
|
134
|
+
say " - #{report[:name]}"
|
135
|
+
report[:tests].each do |test|
|
136
|
+
say " Test: #{test[:name]}"
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def run_ips(group, report_name, test_name)
|
142
|
+
if verbose?
|
143
|
+
say "> IPS for:"
|
144
|
+
say "> #{group[:name]}...", :cyan
|
145
|
+
end
|
146
|
+
|
147
|
+
prepare_output_directory_for_ips
|
148
|
+
|
149
|
+
execute_report(group, report_name) do |report, runtime|
|
150
|
+
Benchmark.ips(time: options[:ips_time], warmup: options[:ips_warmup], quiet: quiet_steps?) do |bm|
|
151
|
+
execute_tests(report, test_name, output: false) do |test, _|
|
152
|
+
test_label = "[#{runtime}] #{test[:control] ? CONTROL_MARKER : TEST_MARKER} #{test[:name]}"
|
153
|
+
bm.item(test_label, &test[:block])
|
154
|
+
end
|
155
|
+
|
156
|
+
# We can persist the results to a file to use to later generate a summary
|
157
|
+
save_to(:ips, group, report, runtime) do |file_name|
|
158
|
+
bm.save!(file_name)
|
159
|
+
end
|
160
|
+
|
161
|
+
bm.compare! if verbose?
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
generate_ips_summary if options[:summary]
|
166
|
+
end
|
167
|
+
#
|
168
|
+
# def run_memory(group, report_name, test_name)
|
169
|
+
# say "> Memory profiling for #{group[:name]}...", :cyan if verbose?
|
170
|
+
# execute_report(group, report_name) do |report, runtime|
|
171
|
+
# execute_tests(report, test_name) do |test, _|
|
172
|
+
# MemoryProfiler.report do
|
173
|
+
# test[:block].call
|
174
|
+
# end.pretty_print
|
175
|
+
# end
|
176
|
+
# end
|
177
|
+
# end
|
178
|
+
#
|
179
|
+
# def run_flamegraph(group, report_name, test_name)
|
180
|
+
# execute_report(group, report_name) do |report, runtime|
|
181
|
+
# execute_tests(report, test_name) do |test, _|
|
182
|
+
# label = "report-#{group[:name]}-#{report[:name]}-#{test[:name]}".gsub(/[^A-Za-z0-9_\-]/, "_")
|
183
|
+
# generate_flamegraph(label) do
|
184
|
+
# test[:block].call
|
185
|
+
# end
|
186
|
+
# end
|
187
|
+
# end
|
188
|
+
# end
|
189
|
+
#
|
190
|
+
# def run_profiling(group, report_name, test_name)
|
191
|
+
# say "> Profiling for #{group[:name]} (iterations: #{options[:iterations]})..." if verbose?
|
192
|
+
# execute_report(group, report_name) do |report, runtime|
|
193
|
+
# execute_tests(report, test_name) do |test, iterations|
|
194
|
+
# data = StackProf.run(mode: :cpu, interval: 100) do
|
195
|
+
# i = 0
|
196
|
+
# while i < iterations
|
197
|
+
# test[:block].call
|
198
|
+
# i += 1
|
199
|
+
# end
|
200
|
+
# end
|
201
|
+
# StackProf::Report.new(data).print_text
|
202
|
+
# end
|
203
|
+
# end
|
204
|
+
# end
|
205
|
+
|
206
|
+
def execute_report(group, report_name, &)
|
207
|
+
runtime = options[:runtime]
|
208
|
+
if runtime == "both" || runtime == "mri"
|
209
|
+
say "| run with MRI" if verbose?
|
210
|
+
execute_on_branch(group, report_name, "mri", &)
|
211
|
+
end
|
212
|
+
if runtime == "both" || runtime == "yjit"
|
213
|
+
say "| run with YJIT" if verbose?
|
214
|
+
raise "YJIT not supported" unless defined?(RubyVM::YJIT) && RubyVM::YJIT.respond_to?(:enable)
|
215
|
+
RubyVM::YJIT.enable
|
216
|
+
execute_on_branch(group, report_name, "yjit", &)
|
217
|
+
end
|
218
|
+
say if verbose?
|
219
|
+
end
|
220
|
+
|
221
|
+
def execute_on_branch(group, report_name, runtime, &)
|
222
|
+
compare_with = options[:compare_with]
|
223
|
+
# run on current branch, then checkout to compare branch and run again
|
224
|
+
say "| git Branch: '#{git_current_branch_name}'" if verbose?
|
225
|
+
execute_group(group, report_name, runtime, &)
|
226
|
+
if compare_with
|
227
|
+
git_change_branch(compare_with) do
|
228
|
+
say "| compare with git Branch: '#{git_current_branch_name}'" if verbose?
|
229
|
+
execute_group(group, report_name, runtime, options[:compare_control], &)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
def execute_group(group, report_name, runtime, include_control = true)
|
235
|
+
group[:reports].each do |report|
|
236
|
+
if report_name
|
237
|
+
next unless report[:name] == report_name
|
238
|
+
end
|
239
|
+
# We dont execute the `control` blocks if include_control is false (eg when we switch branch)
|
240
|
+
run_report = report.dup
|
241
|
+
run_report[:tests] = report[:tests].reject { |test| test[:control] && !include_control }
|
242
|
+
|
243
|
+
say if verbose?
|
244
|
+
say "> --------------------------" if verbose?
|
245
|
+
say "> Report (#{runtime} - branch '#{git_current_branch_name}'): #{report[:name]}"
|
246
|
+
say "> --------------------------" if verbose?
|
247
|
+
say if verbose?
|
248
|
+
yield run_report, runtime
|
249
|
+
say "<< End Report", :magenta if verbose?
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
def execute_tests(report, test_name, output: true, &)
|
254
|
+
iterations = options[:iterations] || 1
|
255
|
+
sorted_tests = report[:tests].sort { _1[:control] ? -1 : 1 }
|
256
|
+
sorted_tests.each do |test|
|
257
|
+
if test_name
|
258
|
+
next unless test[:name] == test_name
|
259
|
+
end
|
260
|
+
if output
|
261
|
+
say "# ***" if verbose?
|
262
|
+
say "# #{test[:control] ? "Control" : "Test"}: #{test[:name]}", :green
|
263
|
+
say "# ***" if verbose?
|
264
|
+
say
|
265
|
+
end
|
266
|
+
test[:block].call # run once to lazy load etc
|
267
|
+
yield test, iterations
|
268
|
+
if output
|
269
|
+
say
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
def generate_flamegraph(label = nil, open: true, ignore_gc: false, interval: 1000, &)
|
275
|
+
fg = Singed::Flamegraph.new(label: label, ignore_gc: ignore_gc, interval: interval)
|
276
|
+
result = fg.record(&)
|
277
|
+
fg.save
|
278
|
+
fg.open if open
|
279
|
+
result
|
280
|
+
end
|
281
|
+
|
282
|
+
def prepare_output_directory_for_ips
|
283
|
+
FileUtils.mkdir_p(temp_dir) unless Dir.exist?(temp_dir)
|
284
|
+
Dir.glob("#{temp_dir}/*.json").each { |file| File.delete(file) }
|
285
|
+
end
|
286
|
+
|
287
|
+
def save_to(type, group, report, runtime)
|
288
|
+
current_branch = git_current_branch_name
|
289
|
+
file_name = "#{temp_dir}/#{type}-#{runtime}-#{current_branch}-#{group[:name]}-#{report[:name]}.json".gsub(/[^A-Za-z0-9\/_\-.]/, "_")
|
290
|
+
say "Saving results to #{file_name}" if verbose?
|
291
|
+
|
292
|
+
awfy_file = "#{temp_dir}/awfy-#{type}-#{group[:name]}-#{report[:name]}.json".gsub(/[^A-Za-z0-9\/_\-.]/, "_")
|
293
|
+
awfy_data = JSON.parse(File.read(awfy_file)) if File.exist?(awfy_file)
|
294
|
+
awfy_data ||= []
|
295
|
+
awfy_data << {type:, group: group[:name], report: report[:name], branch: current_branch, runtime:, output_path: file_name}
|
296
|
+
|
297
|
+
File.write(awfy_file, awfy_data.to_json)
|
298
|
+
yield file_name
|
299
|
+
end
|
300
|
+
|
301
|
+
def load_json(file_name)
|
302
|
+
JSON.parse(File.read(file_name)).map do |result|
|
303
|
+
{
|
304
|
+
label: result["item"],
|
305
|
+
measured_us: result["measured_us"],
|
306
|
+
iter: result["iter"],
|
307
|
+
stats: Benchmark::IPS::Stats::SD.new(result["samples"]),
|
308
|
+
cycles: result["cycles"]
|
309
|
+
}
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
def generate_ips_summary
|
314
|
+
awfy_report_result_files = Dir.glob("#{temp_dir}/awfy-ips-*.json").map do |file_name|
|
315
|
+
JSON.parse(File.read(file_name)).map { _1.transform_keys(&:to_sym) }
|
316
|
+
end
|
317
|
+
|
318
|
+
awfy_report_result_files.each do |report|
|
319
|
+
results = report.map do |single_run|
|
320
|
+
load_json(single_run[:output_path]).map do |result|
|
321
|
+
test_name = result[:label].match(/\[.{3,4}\] \[.\] (.*)/)[1]
|
322
|
+
result.merge!(
|
323
|
+
runtime: single_run[:runtime],
|
324
|
+
test_name: test_name,
|
325
|
+
branch: single_run[:branch]
|
326
|
+
)
|
327
|
+
end
|
328
|
+
end
|
329
|
+
results.flatten!(1)
|
330
|
+
|
331
|
+
base_branch = git_current_branch_name
|
332
|
+
baseline = results.find do |r|
|
333
|
+
r[:branch] == base_branch && r[:label].include?(TEST_MARKER) && r[:runtime] == (yjit_only? ? "yjit" : "mri") # Baseline is mri baseline unless yjit only
|
334
|
+
end
|
335
|
+
unless baseline
|
336
|
+
say_error "Could not work out which result is considered the 'baseline' (ie the `test` case)"
|
337
|
+
exit(1)
|
338
|
+
end
|
339
|
+
baseline[:is_baseline] = true
|
340
|
+
say "> Chosen baseline: #{baseline[:label]}" if verbose?
|
341
|
+
|
342
|
+
result_diffs = results.map do |result|
|
343
|
+
if baseline
|
344
|
+
baseline_stats = baseline[:stats]
|
345
|
+
result_stats = result[:stats]
|
346
|
+
overlaps = result_stats.overlaps?(baseline_stats)
|
347
|
+
diff_x = if baseline_stats.central_tendency > result_stats.central_tendency
|
348
|
+
-1.0 * result_stats.speedup(baseline_stats).first
|
349
|
+
else
|
350
|
+
result_stats.slowdown(baseline_stats).first
|
351
|
+
end
|
352
|
+
end
|
353
|
+
|
354
|
+
result.merge(
|
355
|
+
overlaps: overlaps,
|
356
|
+
diff_times: diff_x
|
357
|
+
)
|
358
|
+
end
|
359
|
+
|
360
|
+
result_diffs.sort_by! { |result| -1 * result[:iter] }
|
361
|
+
|
362
|
+
rows = result_diffs.map do |result|
|
363
|
+
diff_message = if result[:is_baseline]
|
364
|
+
"-"
|
365
|
+
elsif result[:overlaps]
|
366
|
+
"same-ish"
|
367
|
+
elsif result[:diff_times]
|
368
|
+
"#{result[:diff_times].round(2)} x"
|
369
|
+
else
|
370
|
+
"?"
|
371
|
+
end
|
372
|
+
test_name = result[:is_baseline] ? "#{result[:test_name]} (baseline)" : result[:test_name]
|
373
|
+
|
374
|
+
[result[:branch], result[:runtime], test_name, result[:stats].central_tendency.round, diff_message]
|
375
|
+
end
|
376
|
+
|
377
|
+
group_data = report.first
|
378
|
+
table = ::Terminal::Table.new(
|
379
|
+
title: "Summary for #{requested_tests(group_data[:group], group_data[:report])}",
|
380
|
+
headings: ["Branch", "Runtime", "Name", "IPS", "Diff v baseline (times)"],
|
381
|
+
rows: rows
|
382
|
+
)
|
383
|
+
|
384
|
+
table.align_column(2, :right)
|
385
|
+
table.align_column(3, :right)
|
386
|
+
table.align_column(4, :right)
|
387
|
+
|
388
|
+
say table
|
389
|
+
end
|
390
|
+
end
|
391
|
+
|
392
|
+
def git_client
|
393
|
+
@_git_client ||= Git.open(Dir.pwd)
|
394
|
+
end
|
395
|
+
|
396
|
+
def git_change_branch(branch)
|
397
|
+
# TODO: git to checkout branch (and stash first, then pop after)
|
398
|
+
previous_branch = git_current_branch_name
|
399
|
+
say "Switching to branch '#{branch}'" if verbose?
|
400
|
+
git_client.lib.stash_save("awfy auto stash")
|
401
|
+
git_client.checkout(branch)
|
402
|
+
yield
|
403
|
+
ensure
|
404
|
+
say "Switching back to branch '#{previous_branch}'" if verbose?
|
405
|
+
git_client.checkout(previous_branch)
|
406
|
+
git_client.lib.stash_apply(0)
|
407
|
+
end
|
408
|
+
|
409
|
+
def git_current_branch_name = git_client.current_branch
|
410
|
+
|
411
|
+
def yjit_only? = options[:runtime] == "yjit"
|
412
|
+
|
413
|
+
def both_runtimes? = options[:runtime] == "both"
|
414
|
+
|
415
|
+
def temp_dir = options[:temp_output_directory]
|
416
|
+
|
417
|
+
def verbose? = options[:verbose]
|
418
|
+
|
419
|
+
def quiet_steps? = options[:quiet] || options[:summary]
|
420
|
+
end
|
421
|
+
end
|
data/lib/awfy/version.rb
ADDED
data/lib/awfy.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "awfy/version"
|
4
|
+
require_relative "awfy/cli"
|
5
|
+
|
6
|
+
module Awfy
|
7
|
+
class << self
|
8
|
+
def group(name, &)
|
9
|
+
@groups ||= {}
|
10
|
+
@groups[name] ||= {name:, reports: []}.freeze
|
11
|
+
@current_group = @groups[name]
|
12
|
+
instance_eval(&)
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :groups
|
16
|
+
|
17
|
+
def report(name, &)
|
18
|
+
@current_group[:reports] << {name:, tests: []}.freeze
|
19
|
+
instance_eval(&)
|
20
|
+
end
|
21
|
+
|
22
|
+
def control(name, &block)
|
23
|
+
@current_group[:reports].last[:tests] << {name:, block:, control: true}.freeze
|
24
|
+
end
|
25
|
+
|
26
|
+
def test(name, &block)
|
27
|
+
@current_group[:reports].last[:tests] << {name:, block:}.freeze
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/sig/awfy.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: awfy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stephen Ierodiaconou
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-10-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: git
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '2.3'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '3.0'
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '2.3'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '3.0'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: terminal-table
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '3.0'
|
60
|
+
- - "<"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '4.0'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.0'
|
70
|
+
- - "<"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '4.0'
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: benchmark-ips
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '2.14'
|
80
|
+
- - "<"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
type: :runtime
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.14'
|
90
|
+
- - "<"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '3.0'
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: memory_profiler
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '1.1'
|
100
|
+
- - "<"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '2.0'
|
103
|
+
type: :runtime
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '1.1'
|
110
|
+
- - "<"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '2.0'
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: singed
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0.2'
|
120
|
+
- - "<"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '1.0'
|
123
|
+
type: :runtime
|
124
|
+
prerelease: false
|
125
|
+
version_requirements: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0.2'
|
130
|
+
- - "<"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '1.0'
|
133
|
+
- !ruby/object:Gem::Dependency
|
134
|
+
name: stackprof
|
135
|
+
requirement: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0.2'
|
140
|
+
- - "<"
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '1.0'
|
143
|
+
type: :runtime
|
144
|
+
prerelease: false
|
145
|
+
version_requirements: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0.2'
|
150
|
+
- - "<"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '1.0'
|
153
|
+
description: awfy is a benchmarking tool that allows you to define groups of benchmarks
|
154
|
+
and compare against runtimes, branches etc.
|
155
|
+
email:
|
156
|
+
- stevegeek@gmail.com
|
157
|
+
executables:
|
158
|
+
- awfy
|
159
|
+
extensions: []
|
160
|
+
extra_rdoc_files: []
|
161
|
+
files:
|
162
|
+
- ".ruby-version"
|
163
|
+
- ".standard.yml"
|
164
|
+
- CHANGELOG.md
|
165
|
+
- LICENSE.txt
|
166
|
+
- README.md
|
167
|
+
- Rakefile
|
168
|
+
- exe/awfy
|
169
|
+
- lib/awfy.rb
|
170
|
+
- lib/awfy/cli.rb
|
171
|
+
- lib/awfy/version.rb
|
172
|
+
- sig/awfy.rbs
|
173
|
+
homepage: https://github.com/stevegeek/awfy
|
174
|
+
licenses:
|
175
|
+
- MIT
|
176
|
+
metadata:
|
177
|
+
homepage_uri: https://github.com/stevegeek/awfy
|
178
|
+
source_code_uri: https://github.com/stevegeek/awfy
|
179
|
+
post_install_message:
|
180
|
+
rdoc_options: []
|
181
|
+
require_paths:
|
182
|
+
- lib
|
183
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: 3.1.0
|
188
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
|
+
requirements:
|
190
|
+
- - ">="
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: '0'
|
193
|
+
requirements: []
|
194
|
+
rubygems_version: 3.5.16
|
195
|
+
signing_key:
|
196
|
+
specification_version: 4
|
197
|
+
summary: awfy (Are We Fast Yet?) a Benchmarking tool
|
198
|
+
test_files: []
|