stable_profile 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/stable_profile.rb +8 -13
- metadata +21 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fdc1251ab06ef89ebd5900e3159d0783f45c283f47e3e8d536c2f3d264c0f482
|
4
|
+
data.tar.gz: c46a33e840de54c00ff9be23cef7fa31a95340e2ac8b7866e23e3b0733f54ad4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bd390ac4a17735e2d4fab46196c1bce4a3152f1f0b1e958e58d15e03a4b6f83e437fdb8c25fb586f68fcca53b5949201ed10b92ad9076b6417cd948efdc2ab0
|
7
|
+
data.tar.gz: 2b21c63b395890dac6b1a7f4afef4efda08bb727f1ac339ef2899d718b26a2f06a013c4638ad3edbaa4669e26e2e8298becec6c9b17c6f65cc661a4570a078ab
|
data/lib/stable_profile.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'colorize'
|
3
4
|
require 'fileutils'
|
4
5
|
require 'json'
|
5
6
|
require 'ruby-progressbar'
|
@@ -18,15 +19,11 @@ module StableProfile
|
|
18
19
|
TOP_SLOWEST_EXAMPLES = 5
|
19
20
|
|
20
21
|
# The more iterations you run, the more accurate the results will be.
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
ITERATIONS = 20
|
23
|
+
MINIMUM_SAMPLE_SIZE = ITERATIONS * 0.75
|
24
|
+
DECIMAL_PLACES = 4
|
24
25
|
|
25
|
-
|
26
|
-
MINIMUM_SAMPLE_SIZE = ITERATIONS / 2
|
27
|
-
DECIMAL_PLACES = 4
|
28
|
-
|
29
|
-
OUTPUT_DIR = 'tmp/multi_profile'
|
26
|
+
OUTPUT_DIR = 'tmp/stable_profile'
|
30
27
|
|
31
28
|
|
32
29
|
def bold(string)
|
@@ -35,8 +32,6 @@ module StableProfile
|
|
35
32
|
|
36
33
|
|
37
34
|
def run
|
38
|
-
puts "pwd = #{system('pwd')}"
|
39
|
-
|
40
35
|
# Erase and Create the output directory
|
41
36
|
FileUtils.rm_rf(OUTPUT_DIR)
|
42
37
|
FileUtils.mkdir_p(OUTPUT_DIR)
|
@@ -44,7 +39,7 @@ module StableProfile
|
|
44
39
|
# Run the specs ITERATIONS times, each time with a different random seed
|
45
40
|
progressbar = ProgressBar.create(title: 'Running profiles', total: ITERATIONS, format: '%t: |%B| %p%% %a')
|
46
41
|
ITERATIONS.times do |i|
|
47
|
-
system("rspec --profile
|
42
|
+
system("rspec --profile --order random --format json > #{OUTPUT_DIR}/multi_profile_#{i+1}.json")
|
48
43
|
progressbar.increment
|
49
44
|
end
|
50
45
|
|
@@ -91,7 +86,7 @@ module StableProfile
|
|
91
86
|
|
92
87
|
example = record.fetch(:example)
|
93
88
|
|
94
|
-
puts " #{example['full_description']}"
|
89
|
+
puts " #{example['full_description']}".colorize(:light_black)
|
95
90
|
puts bold(" #{record[:average_time]} seconds").ljust(27) + " (N=#{record[:run_times].size})".ljust(7) + " #{example['file_path']}:#{example['line_number']}"
|
96
91
|
end
|
97
92
|
|
@@ -105,7 +100,7 @@ module StableProfile
|
|
105
100
|
|
106
101
|
group = record.fetch(:group)
|
107
102
|
|
108
|
-
puts " #{group['description']}"
|
103
|
+
puts " #{group['description']}".colorize(:light_black)
|
109
104
|
puts bold(" #{record[:average_time]} seconds").ljust(27) + " (N=#{record[:run_times].size})".ljust(7) + " #{group['location']}"
|
110
105
|
end
|
111
106
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stable_profile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robb Shecter
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colorize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: ruby-progressbar
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,7 +94,11 @@ dependencies:
|
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: 3.12.0
|
83
|
-
description:
|
97
|
+
description: 'Solves a quirk of rspec --profile in some code bases: result vary with
|
98
|
+
every random spec ordering. This seems to be due to differences in dependency load
|
99
|
+
order, class initialization, and test server startup. This lib runs rspec --profile
|
100
|
+
many times, averaging the results to always give the same (stable) and meaningful
|
101
|
+
result.'
|
84
102
|
email:
|
85
103
|
- robb@public.law
|
86
104
|
executables:
|