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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 581626c86185aaf6f5155ff71279a5bddc26beac617d894523b97ea534960f08
4
- data.tar.gz: 93b3a57bcde0653c6682e0757137e4f5612e6e4f3444dd4fe94d556ec5ef77a8
3
+ metadata.gz: 2ed7fac91722a804da9125b03501653c1e1d78993b9c7d874e5e597656cb3c12
4
+ data.tar.gz: 5c36d946b6e0533d195f9b285d1d6541e4890a2f2eb37f2ca5d26b4c9434b655
5
5
  SHA512:
6
- metadata.gz: 0e9eb3bd1494b2cca18f2b61adc0bc62794cff238afb6c7713826aaea44f4987648520d735ffd93f2e81b2bd69dc7ac7adc5d0966fda75d3ebdc728ed6c5c476
7
- data.tar.gz: 442a77045473b79c8a4bdeb82e3002f63c3eb1195cc321754ae8ebc905c02d0300c58eb5c95f8488e58b27fb33a7c7ca5a536b99da305a30470b32e2e788a6ef
6
+ metadata.gz: be591fafddeff784a41a817c51f1f0f4c6a7f0b14b80f16b4792c61564af97f22a38f8cc999d5e7431cae3393cbfe427eebb291e2bc2efac7c578a802a870ec7
7
+ data.tar.gz: 4e0fceb32c0acbc09f74c91959121a9033b5ac188700eb225c7d51a4cee796665640302e5e7eed5508c870c63fc26a4370ed1ed6e88b15757fc8c291a70a3c88
@@ -1,4 +1,9 @@
1
- # A Log of Changes!
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
- DERAILED_SCRIPT_COUNT = (ENV["DERAILED_SCRIPT_COUNT"] ||= "200").to_i
7
- ENV["TEST_COUNT"] ||= "200"
6
+ begin
7
+ DERAILED_SCRIPT_COUNT = (ENV["DERAILED_SCRIPT_COUNT"] ||= "200").to_i
8
+ ENV["TEST_COUNT"] ||= "200"
8
9
 
9
- raise "test count must be at least 2, is set to #{DERAILED_SCRIPT_COUNT}" if DERAILED_SCRIPT_COUNT < 2
10
- script = ENV["DERAILED_SCRIPT"] || "bundle exec derailed exec perf:test"
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
- if ENV["DERAILED_PATH_TO_LIBRARY"]
13
- library_dir = ENV["DERAILED_PATH_TO_LIBRARY"]
14
- else
15
- library_dir = DerailedBenchmarks.rails_path_on_disk
16
- end
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
- raise "Must be a path with a .git directory '#{library_dir}'" unless File.exist?(File.join(library_dir, ".git"))
19
-
20
- # Use either the explicit SHAs when present or grab last two SHAs from commit history
21
- # if only one SHA is given, then use it and the last SHA from commit history
22
- branch_names = []
23
- branch_names = ENV.fetch("SHAS_TO_TEST").split(",") if ENV["SHAS_TO_TEST"]
24
- if branch_names.length < 2
25
- Dir.chdir(library_dir) do
26
- branches = run!('git log --format="%H" -n 2').chomp.split($INPUT_RECORD_SEPARATOR)
27
- if branch_names.empty?
28
- branch_names = branches
29
- else
30
- branch_names << branches.shift
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
- current_library_branch = ""
36
- Dir.chdir(library_dir) { current_library_branch = run!('git describe --contains --all HEAD').chomp }
39
+ current_library_branch = ""
40
+ Dir.chdir(library_dir) { current_library_branch = run!('git describe --contains --all HEAD').chomp }
37
41
 
38
- out_dir = Pathname.new("tmp/library_branches/#{Time.now.strftime('%Y-%m-%d-%H-%M-%s-%N')}")
39
- out_dir.mkpath
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
- branches_to_test = branch_names.each_with_object({}) {|elem, hash| hash[elem] = out_dir + "#{elem.gsub('/', ':')}.bench.txt" }
42
- branch_info = {}
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
- branches_to_test.each do |branch, file|
45
- Dir.chdir(library_dir) do
46
- run!("git checkout '#{branch}'")
47
- description = run!("git log --oneline --format=%B -n 1 HEAD | head -n 1").strip
48
- time_stamp = run!("git log -n 1 --pretty=format:%ci").strip # https://stackoverflow.com/a/25921837/147390
49
- name = run!("git rev-parse --short HEAD").strip
50
- branch_info[name] = { desc: description, time: DateTime.parse(time_stamp), file: file }
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
- stats = DerailedBenchmarks::StatsFromDir.new(branch_info)
56
- ENV["DERAILED_STOP_VALID_COUNT"] ||= "50"
57
- stop_valid_count = Integer(ENV["DERAILED_STOP_VALID_COUNT"])
58
-
59
- times_significant = 0
60
- DERAILED_SCRIPT_COUNT.times do |i|
61
- puts "Sample: #{i.next}/#{DERAILED_SCRIPT_COUNT} iterations per sample: #{ENV['TEST_COUNT']}"
62
- branches_to_test.each do |branch, file|
63
- Dir.chdir(library_dir) { run!("git checkout '#{branch}'") }
64
- run!(" #{script} 2>&1 | tail -n 1 >> '#{file}'")
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
- ensure
71
- if library_dir && current_library_branch
72
- puts "Resetting git dir of #{library_dir.inspect} to #{current_library_branch.inspect}"
73
- Dir.chdir(library_dir) do
74
- run!("git checkout '#{current_library_branch}'")
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
- stats.call.banner if stats
79
- end
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DerailedBenchmarks
4
- VERSION = "1.4.1"
4
+ VERSION = "1.4.2"
5
5
  end
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.1
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-10-03 00:00:00.000000000 Z
11
+ date: 2019-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: heapy