derailed_benchmarks 1.4.3 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 348a836be042f2ebf7785075bc3f552c60ef9cefeb979d5dded1fcac5101111a
4
- data.tar.gz: 6c25b2275a5c57ae9abfc6b6c55021869aa8cea9cfcfdda7422df876caf5b10d
3
+ metadata.gz: 596677a7dc15b62f384bbf140c0bbe05eb9c890b73ea66e76c34c115ba0c38c1
4
+ data.tar.gz: 194a74aac18253ad77bb4fcbb464a70478d8127ea894df86e3b8071d6390e264
5
5
  SHA512:
6
- metadata.gz: eb65bb19c23d4c112ae31289c3b610aca98f1541e7a4ee1a6fd1f1b98d1ace4849f061ebb323fc38b2f01ceae64907edd247e36becd849c52fa6998370faef5b
7
- data.tar.gz: 0273f740b7458e1feaa59f05681e815c41ad45830fb8b5590b6860769e4f4e96ee556b5249bb90598b96e987a68bf7f3939fba9837a8573b16f0f4ce7dbc182a
6
+ metadata.gz: 00bc97b216b94edf416d320749b789793f2c6dd2e35b7b56ddd45daaaaec88c61d972cc2b8f52005f9c6cb81f564797377dcd519639b41af366eafe8f88451be
7
+ data.tar.gz: b0bd2f96ca277f47f1696d7339d10bc9e0c580607def3e5bb5bd3550302749bc53a4575f353bb34c7d104e1c7be4e712af44221b7094a04b636f093b1dd0035a
@@ -1,5 +1,14 @@
1
1
  ## master (unreleased)
2
2
 
3
+ ## 1.5.0
4
+
5
+ - Test `perf:library` results against 99% confidence interval in addition to 95% (https://github.com/schneems/derailed_benchmarks/pull/165)
6
+ - Change default, `perf:library` tests do not stop automatically any more (https://github.com/schneems/derailed_benchmarks/pull/164)
7
+
8
+ ## 1.4.4
9
+
10
+ - Fix alignment of deicmals in output (https://github.com/schneems/derailed_benchmarks/pull/161)
11
+
3
12
  ## 1.4.3
4
13
 
5
14
  - perf:library now uses median instead of average (https://github.com/schneems/derailed_benchmarks/pull/160)
data/README.md CHANGED
@@ -453,7 +453,7 @@ You can use this to test changes in other libraries that aren't rails, you just
453
453
 
454
454
  > To get the best results before running tests you should close all programs on your laptop, turn on a program to prevent your laptop from going to sleep (or increase your sleep timer). Make sure it's plugged into a power outlet and go grab a cup of coffee. If you do anything on your laptop while this test is running you risk the chance of skewing your results.
455
455
 
456
- By default derailed will stop once statistical signficance has been detected, you can tune this behavior by setting `DERAILED_STOP_VALID_COUNT` env var. Setting this to a positive number, will increase the number of iterations required that are detected to be statistically significant. For example setting it to 100 might result in 120 runs if it takes 20 runs to detect significance. Generally the more runs you have, the more accurate your averages will be. You can disable this all together by setting `DERAILED_STOP_VALID_COUNT=0` which will force derailed to run all iterations.
456
+ As the test is executing, intermediate results will be printed every 50 iterations.
457
457
 
458
458
  ## Environment Variables
459
459
 
@@ -42,14 +42,25 @@ module DerailedBenchmarks
42
42
 
43
43
  def call
44
44
  @files.each(&:call)
45
- @stats = statistical_test
45
+
46
+ stats_95 = statistical_test(confidence: 95)
47
+
48
+ # If default check is good, see if we also pass a more rigorous test
49
+ # if so, then use the more rigourous test
50
+ if stats_95[:alternative]
51
+ stats_99 = statistical_test(confidence: 99)
52
+ @stats = stats_99 if stats_99[:alternative]
53
+ end
54
+ @stats ||= stats_95
55
+
46
56
  self
47
57
  end
48
58
 
49
- def statistical_test(series_1=oldest.values, series_2=newest.values)
59
+ def statistical_test(series_1=oldest.values, series_2=newest.values, confidence: 95)
50
60
  StatisticalTest::KSTest.two_samples(
51
61
  group_one: series_1,
52
- group_two: series_2
62
+ group_two: series_2,
63
+ alpha: (100 - confidence) / 100.0
53
64
  )
54
65
  end
55
66
 
@@ -86,7 +97,7 @@ module DerailedBenchmarks
86
97
  end
87
98
 
88
99
  def align
89
- " " * (("%i" % percent_faster).length - ("%i" % x_faster).length)
100
+ " " * (percent_faster.to_s.index(".") - x_faster.to_s.index("."))
90
101
  end
91
102
 
92
103
  def banner(io = Kernel)
@@ -107,6 +118,7 @@ module DerailedBenchmarks
107
118
  io.puts "Samples: #{newest.values.length}"
108
119
  io.puts
109
120
  io.puts "Test type: Kolmogorov Smirnov"
121
+ io.puts "Confidence level: #{@stats[:confidence_level] * 100} %"
110
122
  io.puts "Is significant? (max > critical): #{significant?}"
111
123
  io.puts "D critical: #{d_critical}"
112
124
  io.puts "D max: #{d_max}"
@@ -71,18 +71,20 @@ namespace :perf do
71
71
 
72
72
  raise "SHAs to test must be different" if branch_info.length == 1
73
73
  stats = DerailedBenchmarks::StatsFromDir.new(branch_info)
74
- ENV["DERAILED_STOP_VALID_COUNT"] ||= "50"
75
- stop_valid_count = Integer(ENV["DERAILED_STOP_VALID_COUNT"])
74
+ puts "Env var no longer has any affect DERAILED_STOP_VALID_COUNT" if ENV["DERAILED_STOP_VALID_COUNT"]
76
75
 
77
- times_significant = 0
78
76
  DERAILED_SCRIPT_COUNT.times do |i|
79
77
  puts "Sample: #{i.next}/#{DERAILED_SCRIPT_COUNT} iterations per sample: #{ENV['TEST_COUNT']}"
80
78
  branches_to_test.each do |branch, file|
81
79
  Dir.chdir(library_dir) { run!("git checkout '#{branch}'") }
82
80
  run!(" #{script} 2>&1 | tail -n 1 >> '#{file}'")
83
81
  end
84
- times_significant += 1 if i >= 2 && stats.call.significant?
85
- break if stop_valid_count != 0 && times_significant == stop_valid_count
82
+
83
+ if (i % 50).zero?
84
+ puts "Intermediate result"
85
+ stats.call.banner
86
+ puts "Continuing execution"
87
+ end
86
88
  end
87
89
 
88
90
  ensure
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DerailedBenchmarks
4
- VERSION = "1.4.3"
4
+ VERSION = "1.5.0"
5
5
  end
@@ -19,7 +19,7 @@ class StatsFromDirTest < ActiveSupport::TestCase
19
19
  assert_equal "loser", oldest.name
20
20
 
21
21
  assert_in_delta 0.26, stats.d_max, 0.01
22
- assert_in_delta 0.1730818382602285, stats.d_critical, 0.00001
22
+ assert_in_delta 0.2145966026289347, stats.d_critical, 0.00001
23
23
  assert_equal true, stats.significant?
24
24
 
25
25
  format = DerailedBenchmarks::StatsFromDir::FORMAT
@@ -27,7 +27,24 @@ class StatsFromDirTest < ActiveSupport::TestCase
27
27
  assert_equal "0.6147", format % stats.percent_faster
28
28
 
29
29
  assert_equal "11.3844", format % newest.median
30
- end
30
+ end
31
+
32
+ test "alignment" do
33
+ dir = fixtures_dir("stats/significant")
34
+ branch_info = {}
35
+ branch_info["loser"] = { desc: "Old commit", time: Time.now, file: dir.join("loser.bench.txt"), name: "loser" }
36
+ branch_info["winner"] = { desc: "I am the new commit", time: Time.now + 1, file: dir.join("winner.bench.txt"), name: "winner" }
37
+ stats = DerailedBenchmarks::StatsFromDir.new(branch_info).call
38
+ def stats.percent_faster
39
+ -0.1
40
+ end
41
+
42
+ def stats.x_faster
43
+ 0.9922
44
+ end
45
+
46
+ assert_equal 1, stats.align.length
47
+ end
31
48
 
32
49
  test "banner faster" do
33
50
  dir = fixtures_dir("stats/significant")
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.3
4
+ version: 1.5.0
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-12-17 00:00:00.000000000 Z
11
+ date: 2019-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: heapy
@@ -323,7 +323,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
323
323
  - !ruby/object:Gem::Version
324
324
  version: '0'
325
325
  requirements: []
326
- rubygems_version: 3.0.3
326
+ rubygems_version: 3.1.2
327
327
  signing_key:
328
328
  specification_version: 4
329
329
  summary: Benchmarks designed to performance test your ENTIRE site