stable_profile 0.3.0 → 0.4.1
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/lib/stable_profile/cli.rb +2 -0
- data/lib/stable_profile.rb +13 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69f29fc4583e9a306a7aabbf1d9e267e924ea0be97ba6c3c592cc25899a9aa75
|
4
|
+
data.tar.gz: aba44a7c4cc527a500c8e547aeda1d51944e1f2da271df0aec434967f88d6e00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1374fbf762bed4ec91bc9207cd225546480bf68d4b94ce978277905d18360ee992aacad83cc19a45444f39ed9481263c7a831774cccbe9ec0b21f01288c7777
|
7
|
+
data.tar.gz: c761db15d550d213bc0d629874dc2f50acb693d58fba3b656eb841ae590d863f70fafb231bcbd82b37844ebf2ab5aa56a70724e3af0975a2b320b67224bb5773
|
data/lib/stable_profile/cli.rb
CHANGED
data/lib/stable_profile.rb
CHANGED
@@ -4,6 +4,7 @@ require 'fileutils'
|
|
4
4
|
require 'json'
|
5
5
|
require 'ruby-progressbar'
|
6
6
|
|
7
|
+
|
7
8
|
module StableProfile
|
8
9
|
class Error < StandardError; end
|
9
10
|
|
@@ -11,12 +12,6 @@ module StableProfile
|
|
11
12
|
# --iterations 10
|
12
13
|
# --top-slowest-examples 10
|
13
14
|
|
14
|
-
class String
|
15
|
-
def bold
|
16
|
-
"\e[1m#{self}\e[22m"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
15
|
module_function
|
21
16
|
|
22
17
|
# How many items to output in each category.
|
@@ -34,7 +29,14 @@ module StableProfile
|
|
34
29
|
OUTPUT_DIR = 'tmp/multi_profile'
|
35
30
|
|
36
31
|
|
32
|
+
def bold(string)
|
33
|
+
"\e[1m#{string}\e[22m"
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
37
|
def run
|
38
|
+
puts "pwd = #{system('pwd')}"
|
39
|
+
|
38
40
|
# Erase and Create the output directory
|
39
41
|
FileUtils.rm_rf(OUTPUT_DIR)
|
40
42
|
FileUtils.mkdir_p(OUTPUT_DIR)
|
@@ -47,7 +49,9 @@ module StableProfile
|
|
47
49
|
end
|
48
50
|
|
49
51
|
# Read the results from the JSON files into an array.
|
50
|
-
outputs = Dir.glob("#{OUTPUT_DIR}/*.json").map
|
52
|
+
outputs = Dir.glob("#{OUTPUT_DIR}/*.json").map do |file|
|
53
|
+
JSON.parse(File.read(file))
|
54
|
+
end
|
51
55
|
|
52
56
|
# Extract the JSON profile structures from the full results.
|
53
57
|
profile_blocks = outputs.map { |output| output.fetch('profile') }
|
@@ -88,7 +92,7 @@ module StableProfile
|
|
88
92
|
example = record.fetch(:example)
|
89
93
|
|
90
94
|
puts " #{example['full_description']}"
|
91
|
-
puts " #{record[:average_time]} seconds".
|
95
|
+
puts bold(" #{record[:average_time]} seconds").ljust(27) + " (N=#{record[:run_times].size})".ljust(7) + " #{example['file_path']}:#{example['line_number']}"
|
92
96
|
end
|
93
97
|
|
94
98
|
puts
|
@@ -102,7 +106,7 @@ module StableProfile
|
|
102
106
|
group = record.fetch(:group)
|
103
107
|
|
104
108
|
puts " #{group['description']}"
|
105
|
-
puts " #{record[:average_time]} seconds".
|
109
|
+
puts bold(" #{record[:average_time]} seconds").ljust(27) + " (N=#{record[:run_times].size})".ljust(7) + " #{group['location']}"
|
106
110
|
end
|
107
111
|
end
|
108
112
|
end
|