derailed_benchmarks 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/lib/derailed_benchmarks/tasks.rb +79 -59
- data/lib/derailed_benchmarks/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ed7fac91722a804da9125b03501653c1e1d78993b9c7d874e5e597656cb3c12
|
4
|
+
data.tar.gz: 5c36d946b6e0533d195f9b285d1d6541e4890a2f2eb37f2ca5d26b4c9434b655
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be591fafddeff784a41a817c51f1f0f4c6a7f0b14b80f16b4792c61564af97f22a38f8cc999d5e7431cae3393cbfe427eebb291e2bc2efac7c578a802a870ec7
|
7
|
+
data.tar.gz: 4e0fceb32c0acbc09f74c91959121a9033b5ac188700eb225c7d51a4cee796665640302e5e7eed5508c870c63fc26a4370ed1ed6e88b15757fc8c291a70a3c88
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
|
1
|
+
## master (unreleased)
|
2
|
+
|
3
|
+
## 1.4.2
|
4
|
+
|
5
|
+
- Fixed syntax error that resulted in ensure end error inside tasks.rb for older rubies (https://github.com/schneems/derailed_benchmarks/pull/155)
|
6
|
+
- Fix case in perf:library where the same SHA could be tested against itself (https://github.com/schneems/derailed_benchmarks/pull/153)
|
2
7
|
|
3
8
|
## 1.4.1
|
4
9
|
|
@@ -3,80 +3,100 @@ require_relative 'load_tasks'
|
|
3
3
|
namespace :perf do
|
4
4
|
desc "runs the same test against two different branches for statistical comparison"
|
5
5
|
task :library do
|
6
|
-
|
7
|
-
|
6
|
+
begin
|
7
|
+
DERAILED_SCRIPT_COUNT = (ENV["DERAILED_SCRIPT_COUNT"] ||= "200").to_i
|
8
|
+
ENV["TEST_COUNT"] ||= "200"
|
8
9
|
|
9
|
-
|
10
|
-
|
10
|
+
raise "test count must be at least 2, is set to #{DERAILED_SCRIPT_COUNT}" if DERAILED_SCRIPT_COUNT < 2
|
11
|
+
script = ENV["DERAILED_SCRIPT"] || "bundle exec derailed exec perf:test"
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
if ENV["DERAILED_PATH_TO_LIBRARY"]
|
14
|
+
library_dir = ENV["DERAILED_PATH_TO_LIBRARY"]
|
15
|
+
else
|
16
|
+
library_dir = DerailedBenchmarks.rails_path_on_disk
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
19
|
+
raise "Must be a path with a .git directory '#{library_dir}'" unless File.exist?(File.join(library_dir, ".git"))
|
20
|
+
|
21
|
+
# Use either the explicit SHAs when present or grab last two SHAs from commit history
|
22
|
+
# if only one SHA is given, then use it and the last SHA from commit history
|
23
|
+
branch_names = []
|
24
|
+
branch_names = ENV.fetch("SHAS_TO_TEST").split(",") if ENV["SHAS_TO_TEST"]
|
25
|
+
if branch_names.length < 2
|
26
|
+
Dir.chdir(library_dir) do
|
27
|
+
run!("git checkout '#{branch_names.first}'") unless branch_names.empty?
|
28
|
+
|
29
|
+
branches = run!('git log --format="%H" -n 2').chomp.split($/)
|
30
|
+
if branch_names.empty?
|
31
|
+
branch_names = branches
|
32
|
+
else
|
33
|
+
branches.shift
|
34
|
+
branch_names << branches.shift
|
35
|
+
end
|
31
36
|
end
|
32
37
|
end
|
33
|
-
end
|
34
38
|
|
35
|
-
|
36
|
-
|
39
|
+
current_library_branch = ""
|
40
|
+
Dir.chdir(library_dir) { current_library_branch = run!('git describe --contains --all HEAD').chomp }
|
37
41
|
|
38
|
-
|
39
|
-
|
42
|
+
out_dir = Pathname.new("tmp/library_branches/#{Time.now.strftime('%Y-%m-%d-%H-%M-%s-%N')}")
|
43
|
+
out_dir.mkpath
|
40
44
|
|
41
|
-
|
42
|
-
|
45
|
+
branches_to_test = branch_names.each_with_object({}) {|elem, hash| hash[elem] = out_dir + "#{elem.gsub('/', ':')}.bench.txt" }
|
46
|
+
branch_info = {}
|
47
|
+
branch_to_sha = {}
|
43
48
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
branches_to_test.each do |branch, file|
|
50
|
+
Dir.chdir(library_dir) do
|
51
|
+
run!("git checkout '#{branch}'")
|
52
|
+
description = run!("git log --oneline --format=%B -n 1 HEAD | head -n 1").strip
|
53
|
+
time_stamp = run!("git log -n 1 --pretty=format:%ci").strip # https://stackoverflow.com/a/25921837/147390
|
54
|
+
short_sha = run!("git rev-parse --short HEAD").strip
|
55
|
+
branch_to_sha[branch] = short_sha
|
56
|
+
|
57
|
+
branch_info[short_sha] = { desc: description, time: DateTime.parse(time_stamp), file: file }
|
58
|
+
end
|
59
|
+
run!("#{script}")
|
51
60
|
end
|
52
|
-
run!("#{script}")
|
53
|
-
end
|
54
61
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
62
|
+
puts
|
63
|
+
puts
|
64
|
+
branches_to_test.each.with_index do |(branch, _), i|
|
65
|
+
short_sha = branch_to_sha[branch]
|
66
|
+
desc = branch_info[short_sha][:desc]
|
67
|
+
puts "Testing #{i + 1}: #{short_sha}: #{desc}"
|
68
|
+
end
|
69
|
+
puts
|
70
|
+
puts
|
71
|
+
|
72
|
+
raise "SHAs to test must be different" if branch_info.length == 1
|
73
|
+
stats = DerailedBenchmarks::StatsFromDir.new(branch_info)
|
74
|
+
ENV["DERAILED_STOP_VALID_COUNT"] ||= "50"
|
75
|
+
stop_valid_count = Integer(ENV["DERAILED_STOP_VALID_COUNT"])
|
76
|
+
|
77
|
+
times_significant = 0
|
78
|
+
DERAILED_SCRIPT_COUNT.times do |i|
|
79
|
+
puts "Sample: #{i.next}/#{DERAILED_SCRIPT_COUNT} iterations per sample: #{ENV['TEST_COUNT']}"
|
80
|
+
branches_to_test.each do |branch, file|
|
81
|
+
Dir.chdir(library_dir) { run!("git checkout '#{branch}'") }
|
82
|
+
run!(" #{script} 2>&1 | tail -n 1 >> '#{file}'")
|
83
|
+
end
|
84
|
+
times_significant += 1 if i >= 2 && stats.call.significant?
|
85
|
+
break if stop_valid_count != 0 && times_significant == stop_valid_count
|
65
86
|
end
|
66
|
-
times_significant += 1 if i >= 2 && stats.call.significant?
|
67
|
-
break if stop_valid_count != 0 && times_significant == stop_valid_count
|
68
|
-
end
|
69
87
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
88
|
+
ensure
|
89
|
+
if library_dir && current_library_branch
|
90
|
+
puts "Resetting git dir of '#{library_dir.to_s}' to #{current_library_branch.inspect}"
|
91
|
+
Dir.chdir(library_dir) do
|
92
|
+
run!("git checkout '#{current_library_branch}'")
|
93
|
+
end
|
75
94
|
end
|
76
|
-
end
|
77
95
|
|
78
|
-
|
79
|
-
|
96
|
+
stats.call.banner if stats
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
80
100
|
|
81
101
|
desc "hits the url TEST_COUNT times"
|
82
102
|
task :test => [:setup] do
|
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.2
|
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-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: heapy
|