stable_profile 0.4.0 → 0.4.1
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 +12 -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.rb
CHANGED
@@ -12,12 +12,6 @@ module StableProfile
|
|
12
12
|
# --iterations 10
|
13
13
|
# --top-slowest-examples 10
|
14
14
|
|
15
|
-
class String
|
16
|
-
def bold
|
17
|
-
"\e[1m#{self}\e[22m"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
15
|
module_function
|
22
16
|
|
23
17
|
# How many items to output in each category.
|
@@ -35,7 +29,14 @@ module StableProfile
|
|
35
29
|
OUTPUT_DIR = 'tmp/multi_profile'
|
36
30
|
|
37
31
|
|
32
|
+
def bold(string)
|
33
|
+
"\e[1m#{string}\e[22m"
|
34
|
+
end
|
35
|
+
|
36
|
+
|
38
37
|
def run
|
38
|
+
puts "pwd = #{system('pwd')}"
|
39
|
+
|
39
40
|
# Erase and Create the output directory
|
40
41
|
FileUtils.rm_rf(OUTPUT_DIR)
|
41
42
|
FileUtils.mkdir_p(OUTPUT_DIR)
|
@@ -48,7 +49,9 @@ module StableProfile
|
|
48
49
|
end
|
49
50
|
|
50
51
|
# Read the results from the JSON files into an array.
|
51
|
-
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
|
52
55
|
|
53
56
|
# Extract the JSON profile structures from the full results.
|
54
57
|
profile_blocks = outputs.map { |output| output.fetch('profile') }
|
@@ -89,7 +92,7 @@ module StableProfile
|
|
89
92
|
example = record.fetch(:example)
|
90
93
|
|
91
94
|
puts " #{example['full_description']}"
|
92
|
-
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']}"
|
93
96
|
end
|
94
97
|
|
95
98
|
puts
|
@@ -103,7 +106,7 @@ module StableProfile
|
|
103
106
|
group = record.fetch(:group)
|
104
107
|
|
105
108
|
puts " #{group['description']}"
|
106
|
-
puts " #{record[:average_time]} seconds".
|
109
|
+
puts bold(" #{record[:average_time]} seconds").ljust(27) + " (N=#{record[:run_times].size})".ljust(7) + " #{group['location']}"
|
107
110
|
end
|
108
111
|
end
|
109
112
|
end
|