pry-auto_benching.rb 1.2.0 → 1.3.0
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/README.md +5 -3
- data/lib/pry-auto_benching/version.rb +1 -1
- data/lib/pry-auto_benching.rb +3 -4
- 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: ee29d04eb0fa35fcebea243a1d411d9e9163fa50d0055ff60546677558e7f249
|
4
|
+
data.tar.gz: 429e451131c12ce282de19a9275a57e8d4ad580565fd441ce872b721e4dbb0e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2011eca5212e3cf1c072ec497660957987c45c9b1d4f3abffccd7f6b3db9fc941b4be47ce67fae6339d3380ba540bf6e9de228953ce7e426c8a95424b996fb8d
|
7
|
+
data.tar.gz: 57e55c6f5f972ead96676bdbeceb3186898886287186bcba36abb61631a80cbc2560a83cface0a85f1ad1e7e41aaa54fc82eda5e18e923eebd24992eb9032de0
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+

|
2
|
+
|
1
3
|
# pry-auto_benching.rb
|
2
4
|
|
3
5
|
pry-auto_benching.rb automatically benchmarks input entered into Pry.
|
@@ -12,8 +14,8 @@ Pry.configure do |config|
|
|
12
14
|
# Start benchmarking as soon as Pry starts? default is true.
|
13
15
|
config.auto_benching.enabled = false
|
14
16
|
|
15
|
-
# Benchmark Pry commands? Default is
|
16
|
-
config.auto_benching.benchmark_commands =
|
17
|
+
# Benchmark Pry commands? Default is true
|
18
|
+
config.auto_benching.benchmark_commands = false
|
17
19
|
|
18
20
|
# The type of clock to use, default is Process::CLOCK_MONOTONIC.
|
19
21
|
# See https://www.rubydoc.info/stdlib/core/Process:clock_gettime
|
@@ -24,7 +26,7 @@ Pry.configure do |config|
|
|
24
26
|
config.auto_benching.target_display = ':prompt | :output'
|
25
27
|
|
26
28
|
# Benchmark results are printed depending on the return value
|
27
|
-
# of this lambda, by default results are printed
|
29
|
+
# of this lambda, by default results are always printed.
|
28
30
|
config.auto_benching.speak_if = ->(pry, duration) {
|
29
31
|
duration > 0.5
|
30
32
|
}
|
data/lib/pry-auto_benching.rb
CHANGED
@@ -22,7 +22,7 @@ module Pry::AutoBenching
|
|
22
22
|
|
23
23
|
AFTER_EVAL = ->(input, pry) do
|
24
24
|
clock_type = pry.config.auto_benching.clock_type
|
25
|
-
duration = (sprintf "%.2f", Process.clock_gettime(clock_type) - MEMORY[pry.hash]
|
25
|
+
duration = (sprintf "%.2f", Process.clock_gettime(clock_type) - MEMORY[pry.hash].pop).to_f
|
26
26
|
if input.nil? # Pry command
|
27
27
|
if pry.config.auto_benching.benchmark_commands and
|
28
28
|
pry.config.auto_benching.speak_if.call(pry, duration)
|
@@ -36,7 +36,6 @@ module Pry::AutoBenching
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
pry.config.prompt_name = 'pry' if pry.config.auto_benching.target_display != :prompt
|
39
|
-
MEMORY[pry.hash].clear
|
40
39
|
end
|
41
40
|
|
42
41
|
BEFORE_SESSION = ->(_,_, pry) do
|
@@ -96,8 +95,8 @@ Pry.configure do |config|
|
|
96
95
|
target_display: :prompt,
|
97
96
|
prompt_color: :green,
|
98
97
|
clock_type: Process::CLOCK_MONOTONIC,
|
99
|
-
benchmark_commands:
|
100
|
-
speak_if: ->(pry, duration) {
|
98
|
+
benchmark_commands: true,
|
99
|
+
speak_if: ->(pry, duration) { true },
|
101
100
|
speaker: ->(pry, duration) {
|
102
101
|
pry.pager.page format("%{AutoBenchingSays} %{Duration}s", {
|
103
102
|
:AutoBenchingSays => pry.color ?
|