derailed_benchmarks 1.4.2 → 1.4.3
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/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/derailed_benchmarks/stats_from_dir.rb +19 -7
- data/lib/derailed_benchmarks/stats_in_file.rb +7 -0
- data/lib/derailed_benchmarks/tasks.rb +12 -4
- data/lib/derailed_benchmarks/version.rb +1 -1
- data/test/derailed_benchmarks/stats_from_dir_test.rb +14 -11
- data/test/rails_app/app/assets/config/manifest.js +0 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 348a836be042f2ebf7785075bc3f552c60ef9cefeb979d5dded1fcac5101111a
|
4
|
+
data.tar.gz: 6c25b2275a5c57ae9abfc6b6c55021869aa8cea9cfcfdda7422df876caf5b10d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb65bb19c23d4c112ae31289c3b610aca98f1541e7a4ee1a6fd1f1b98d1ace4849f061ebb323fc38b2f01ceae64907edd247e36becd849c52fa6998370faef5b
|
7
|
+
data.tar.gz: 0273f740b7458e1feaa59f05681e815c41ad45830fb8b5590b6860769e4f4e96ee556b5249bb90598b96e987a68bf7f3939fba9837a8573b16f0f4ce7dbc182a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
## master (unreleased)
|
2
2
|
|
3
|
+
## 1.4.3
|
4
|
+
|
5
|
+
- perf:library now uses median instead of average (https://github.com/schneems/derailed_benchmarks/pull/160)
|
6
|
+
|
3
7
|
## 1.4.2
|
4
8
|
|
5
9
|
- Fixed syntax error that resulted in ensure end error inside tasks.rb for older rubies (https://github.com/schneems/derailed_benchmarks/pull/155)
|
data/README.md
CHANGED
@@ -431,7 +431,7 @@ Use a comma to seperate your branch names with the `SHAS_TO_TEST` env var, or om
|
|
431
431
|
|
432
432
|
If you only include one SHA, then derailed will grab the latest commit and compare it to that SHA.
|
433
433
|
|
434
|
-
These tests might take a along time to run so the output is stored on disk incase you want to see them in the future, they're at `tmp/
|
434
|
+
These tests might take a along time to run so the output is stored on disk incase you want to see them in the future, they're at `tmp/compare_branches/<timestamp>` and labeled with the same names as your commits.
|
435
435
|
|
436
436
|
When the test is done it will output which commit "won" and by how much:
|
437
437
|
|
@@ -66,15 +66,27 @@ module DerailedBenchmarks
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def x_faster
|
69
|
-
|
69
|
+
(oldest.median/newest.median).to_f
|
70
|
+
end
|
71
|
+
|
72
|
+
def faster?
|
73
|
+
newest.median < oldest.median
|
70
74
|
end
|
71
75
|
|
72
76
|
def percent_faster
|
73
|
-
|
77
|
+
(((oldest.median - newest.median) / oldest.median).to_f * 100)
|
74
78
|
end
|
75
79
|
|
76
80
|
def change_direction
|
77
|
-
|
81
|
+
if faster?
|
82
|
+
"FASTER 🚀🚀🚀"
|
83
|
+
else
|
84
|
+
"SLOWER 🐢🐢🐢"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def align
|
89
|
+
" " * (("%i" % percent_faster).length - ("%i" % x_faster).length)
|
78
90
|
end
|
79
91
|
|
80
92
|
def banner(io = Kernel)
|
@@ -85,11 +97,11 @@ module DerailedBenchmarks
|
|
85
97
|
io.puts "👎👎👎(NOT Statistically Significant) 👎👎👎"
|
86
98
|
end
|
87
99
|
io.puts
|
88
|
-
io.puts "[#{newest.name}] #{newest.desc.inspect} - (#{newest.
|
100
|
+
io.puts "[#{newest.name}] #{newest.desc.inspect} - (#{newest.median} seconds)"
|
89
101
|
io.puts " #{change_direction} by:"
|
90
|
-
io.puts " #{x_faster}x [older/newer]"
|
91
|
-
io.puts " #{percent_faster}\% [(older - newer) / older * 100]"
|
92
|
-
io.puts "[#{oldest.name}] #{oldest.desc.inspect} - (#{oldest.
|
102
|
+
io.puts " #{align}#{FORMAT % x_faster}x [older/newer]"
|
103
|
+
io.puts " #{FORMAT % percent_faster}\% [(older - newer) / older * 100]"
|
104
|
+
io.puts "[#{oldest.name}] #{oldest.desc.inspect} - (#{oldest.median} seconds)"
|
93
105
|
io.puts
|
94
106
|
io.puts "Iterations per sample: #{ENV["TEST_COUNT"]}"
|
95
107
|
io.puts "Samples: #{newest.values.length}"
|
@@ -30,9 +30,14 @@ module DerailedBenchmarks
|
|
30
30
|
def call
|
31
31
|
load_file!
|
32
32
|
|
33
|
+
@median = (values[(values.length - 1) / 2] + values[values.length/ 2]) / 2.0
|
33
34
|
@average = values.inject(:+) / values.length
|
34
35
|
end
|
35
36
|
|
37
|
+
def median
|
38
|
+
@median.to_f
|
39
|
+
end
|
40
|
+
|
36
41
|
def average
|
37
42
|
@average.to_f
|
38
43
|
end
|
@@ -47,6 +52,8 @@ module DerailedBenchmarks
|
|
47
52
|
raise e, "Problem with file #{@file.inspect}:\n#{@file.read}\n#{e.message}"
|
48
53
|
end
|
49
54
|
end
|
55
|
+
|
56
|
+
values.sort!
|
50
57
|
values.freeze
|
51
58
|
end
|
52
59
|
end
|
@@ -39,7 +39,7 @@ namespace :perf do
|
|
39
39
|
current_library_branch = ""
|
40
40
|
Dir.chdir(library_dir) { current_library_branch = run!('git describe --contains --all HEAD').chomp }
|
41
41
|
|
42
|
-
out_dir = Pathname.new("tmp/
|
42
|
+
out_dir = Pathname.new("tmp/compare_branches/#{Time.now.strftime('%Y-%m-%d-%H-%M-%s-%N')}")
|
43
43
|
out_dir.mkpath
|
44
44
|
|
45
45
|
branches_to_test = branch_names.each_with_object({}) {|elem, hash| hash[elem] = out_dir + "#{elem.gsub('/', ':')}.bench.txt" }
|
@@ -93,10 +93,18 @@ namespace :perf do
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
-
|
96
|
+
if stats
|
97
|
+
stats.call.banner
|
98
|
+
|
99
|
+
result_file = out_dir + "results.txt"
|
100
|
+
File.open(result_file, "w") do |f|
|
101
|
+
stats.banner(f)
|
102
|
+
end
|
103
|
+
|
104
|
+
puts "Output: #{result_file.to_s}"
|
105
|
+
end
|
97
106
|
end
|
98
|
-
|
99
|
-
|
107
|
+
end
|
100
108
|
|
101
109
|
desc "hits the url TEST_COUNT times"
|
102
110
|
task :test => [:setup] do
|
@@ -22,8 +22,11 @@ class StatsFromDirTest < ActiveSupport::TestCase
|
|
22
22
|
assert_in_delta 0.1730818382602285, stats.d_critical, 0.00001
|
23
23
|
assert_equal true, stats.significant?
|
24
24
|
|
25
|
-
|
26
|
-
assert_equal "
|
25
|
+
format = DerailedBenchmarks::StatsFromDir::FORMAT
|
26
|
+
assert_equal "1.0062", format % stats.x_faster
|
27
|
+
assert_equal "0.6147", format % stats.percent_faster
|
28
|
+
|
29
|
+
assert_equal "11.3844", format % newest.median
|
27
30
|
end
|
28
31
|
|
29
32
|
test "banner faster" do
|
@@ -44,17 +47,17 @@ class StatsFromDirTest < ActiveSupport::TestCase
|
|
44
47
|
"0.001"
|
45
48
|
end
|
46
49
|
|
47
|
-
def newest.
|
50
|
+
def newest.median
|
48
51
|
10.5
|
49
52
|
end
|
50
53
|
|
51
|
-
def oldest.
|
54
|
+
def oldest.median
|
52
55
|
11.0
|
53
56
|
end
|
54
57
|
|
55
|
-
expected =
|
58
|
+
expected = <<~EOM
|
56
59
|
[winner] "I am the new commit" - (10.5 seconds)
|
57
|
-
FASTER by:
|
60
|
+
FASTER 🚀🚀🚀 by:
|
58
61
|
1.0476x [older/newer]
|
59
62
|
4.5455% [(older - newer) / older * 100]
|
60
63
|
[loser] "Old commit" - (11.0 seconds)
|
@@ -75,18 +78,18 @@ EOM
|
|
75
78
|
newest = stats.newest
|
76
79
|
oldest = stats.oldest
|
77
80
|
|
78
|
-
def oldest.
|
81
|
+
def oldest.median
|
79
82
|
10.5
|
80
83
|
end
|
81
84
|
|
82
|
-
def newest.
|
85
|
+
def newest.median
|
83
86
|
11.0
|
84
87
|
end
|
85
88
|
|
86
|
-
expected =
|
89
|
+
expected = <<~EOM
|
87
90
|
[loser] "I am the new commit" - (11.0 seconds)
|
88
|
-
SLOWER by:
|
89
|
-
|
91
|
+
SLOWER 🐢🐢🐢 by:
|
92
|
+
0.9545x [older/newer]
|
90
93
|
-4.7619% [(older - newer) / older * 100]
|
91
94
|
[winner] "Old commit" - (10.5 seconds)
|
92
95
|
EOM
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: derailed_benchmarks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Schneeman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: heapy
|
@@ -257,6 +257,7 @@ files:
|
|
257
257
|
- test/fixtures/stats/significant/winner.bench.txt
|
258
258
|
- test/integration/tasks_test.rb
|
259
259
|
- test/rails_app/Rakefile
|
260
|
+
- test/rails_app/app/assets/config/manifest.js
|
260
261
|
- test/rails_app/app/assets/javascripts/authenticated.js
|
261
262
|
- test/rails_app/app/assets/stylesheets/authenticated.css
|
262
263
|
- test/rails_app/app/controllers/application_controller.rb
|
@@ -341,6 +342,7 @@ test_files:
|
|
341
342
|
- test/fixtures/stats/significant/winner.bench.txt
|
342
343
|
- test/integration/tasks_test.rb
|
343
344
|
- test/rails_app/Rakefile
|
345
|
+
- test/rails_app/app/assets/config/manifest.js
|
344
346
|
- test/rails_app/app/assets/javascripts/authenticated.js
|
345
347
|
- test/rails_app/app/assets/stylesheets/authenticated.css
|
346
348
|
- test/rails_app/app/controllers/application_controller.rb
|