pry-auto_benching.rb 2.9.1 → 2.10.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/CHANGELOG.md +6 -0
- data/README.md +34 -22
- data/lib/pry-auto_benching/pry_command.rb +12 -7
- data/lib/pry-auto_benching/version.rb +1 -1
- data/lib/pry-auto_benching.rb +2 -0
- data/pry-auto_benching.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2be7a623c19ec705b54bd6e0f47ebd01861c5d97706e81f116585214217ec64e
|
4
|
+
data.tar.gz: ec602812de40fde4c93f0f10da7eb9c138946dd88e021fd18e9cd142033467de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f621e493069445c89cd78ced4684419d3eaddc42939487793ce32fec8717d8bf41a38da7b860ea46f088068db5af62a71489c24019392ebbc1d8e46a28f5b63
|
7
|
+
data.tar.gz: a394d268ae3eaeb41858fb6d53862167d963978531bf94c5c6f716cb93c036ac3e96b05984800aaa67ee5a0b3cf6e4d7932002a09834f1ec634614cf4d937a56
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## v2.10.0
|
4
|
+
|
5
|
+
* Add 'none' as a possible target display.
|
6
|
+
When chosen benchmark results are not written to a display but are still
|
7
|
+
recorded and can be viewed on demand by running `auto-benching --past`.
|
8
|
+
|
3
9
|
## v2.9.1
|
4
10
|
|
5
11
|
* Fix a bug where `MomentList` would not cycle oldest entries first.
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# pry-auto_benching.rb
|
2
2
|
|
3
|
-
pry-auto_benching.rb
|
3
|
+
pry-auto_benching.rb automates benchmarking in Pry.
|
4
4
|
|
5
5
|
## Configuration (optional)
|
6
6
|
|
@@ -20,9 +20,18 @@ Pry.configure do |config|
|
|
20
20
|
# See https://www.rubydoc.info/stdlib/core/Process:clock_gettime
|
21
21
|
config.auto_benching.clock_type = Process::CLOCK_REALTIME
|
22
22
|
|
23
|
-
# Configure where benchmark results
|
24
|
-
#
|
25
|
-
|
23
|
+
# Configure where benchmark results will be displayed.
|
24
|
+
# Valid options are:
|
25
|
+
# * prompt
|
26
|
+
# The default, results are written to the prompt.
|
27
|
+
#
|
28
|
+
# * output
|
29
|
+
# Results are written directly to `_pry_.output`
|
30
|
+
#
|
31
|
+
# * none
|
32
|
+
# Results are not displayed but are still recorded and can be viewed on
|
33
|
+
# demand by running 'auto-benching --past'.
|
34
|
+
config.auto_benching.target_display = ':prompt | :output | :none'
|
26
35
|
|
27
36
|
# Benchmark results are printed or not depending on the return value
|
28
37
|
# of this lambda, by default results are printed when duration >= 0.01.
|
@@ -54,20 +63,13 @@ Show help by running `auto-benching -h`:
|
|
54
63
|
|
55
64
|
-v, --version Display version.
|
56
65
|
-p, --past Display past benchmark results.
|
57
|
-
-t, --target-display Choose the target display for results. Valid options are: stdout, prompt
|
66
|
+
-t, --target-display Choose the target display for results. Valid options are: stdout, prompt, none
|
58
67
|
-h, --help Show this message.
|
59
68
|
|
60
69
|
__2.__
|
61
70
|
|
62
|
-
|
63
|
-
|
64
|
-
[5] pry(main)> auto-benching disable
|
65
|
-
pry-auto_benching.rb: stopped benchmarking.
|
66
|
-
[6] pry(main)>
|
67
|
-
|
68
|
-
__3.__
|
69
|
-
|
70
|
-
An example showing the prompt being updated with benchmark results.
|
71
|
+
An example showing the prompt being updated with benchmark results. <br>
|
72
|
+
This is the default.
|
71
73
|
|
72
74
|
[7] pry(main)> sleep 0.2
|
73
75
|
=> 0
|
@@ -77,9 +79,9 @@ An example showing the prompt being updated with benchmark results.
|
|
77
79
|
=> #<Net::HTTPOK 200 OK readbody=true>
|
78
80
|
[10] 1.53s (main)>
|
79
81
|
|
80
|
-
|
82
|
+
__3.__
|
81
83
|
|
82
|
-
An example
|
84
|
+
An example showing `:output` set as the `target_display`.
|
83
85
|
|
84
86
|
[6] pry(main)> auto-benching --target-display output
|
85
87
|
Display changed to 'output'
|
@@ -93,9 +95,10 @@ An example with `:output` set as the `target_display`.
|
|
93
95
|
pry-auto_benching.rb: 0.31s
|
94
96
|
=> #<Net::HTTPOK 200 OK readbody=true>
|
95
97
|
|
96
|
-
|
98
|
+
__4.__
|
97
99
|
|
98
|
-
|
100
|
+
Displaying a history of benchmark results for the current Pry session using
|
101
|
+
`auto-benching --past`:
|
99
102
|
|
100
103
|
[6] 0.5s (main)> auto-benching --past
|
101
104
|
1. Net::HTTP.get_response URI.parse('https://github.com') (0.88s)
|
@@ -104,6 +107,15 @@ Display a history of benchmark results for the current Pry session using `auto-b
|
|
104
107
|
4. sleep 0.5 (0.5s)
|
105
108
|
[7] pry(main)>
|
106
109
|
|
110
|
+
__5.__
|
111
|
+
|
112
|
+
Disable auto benchmarking for the current Pry session by running
|
113
|
+
`auto-benching disable`:
|
114
|
+
|
115
|
+
[5] pry(main)> auto-benching disable
|
116
|
+
pry-auto_benching.rb: stopped benchmarking.
|
117
|
+
[6] pry(main)>
|
118
|
+
|
107
119
|
## Accuracy
|
108
120
|
|
109
121
|
pry-auto_benching.rb can measure down to 10 milliseconds (0.01 = 10 milliseconds). <br>
|
@@ -115,12 +127,12 @@ Benchmarking `sleep 0.01` shows no overhead in the results:
|
|
115
127
|
|
116
128
|
But it is possible results can be reported inaccurately since the measurement
|
117
129
|
includes a **very** small number of method calls to Pry internals, and it could
|
118
|
-
include time spent by other Pry plugins. I have seen inaccuracies of
|
130
|
+
include time spent by other Pry plugins as well. I have seen inaccuracies of
|
119
131
|
10ms (0.01) but not all the time.
|
120
132
|
|
121
|
-
The overhead
|
122
|
-
|
123
|
-
|
133
|
+
The overhead could be considered negligible, although other Pry plugins running
|
134
|
+
before/after eval hooks and spending a lot of time doing that could skew results
|
135
|
+
more than is expected.
|
124
136
|
|
125
137
|
## Integration with custom prompts
|
126
138
|
|
@@ -3,7 +3,7 @@ Pry::Commands.add_command Class.new(Pry::ClassCommand) {
|
|
3
3
|
match 'auto-benching'
|
4
4
|
command_options argument_required: true
|
5
5
|
group 'pry-auto_benching.rb'
|
6
|
-
description '
|
6
|
+
description 'For enabling and disabling benchmarking and other related features.'
|
7
7
|
banner <<-CMDBANNER
|
8
8
|
Usage: auto-benching [options] [enable|disable]
|
9
9
|
|
@@ -16,14 +16,19 @@ Pry::Commands.add_command Class.new(Pry::ClassCommand) {
|
|
16
16
|
o.on :p, :past, 'Display past benchmark results.'
|
17
17
|
o.on :t,
|
18
18
|
:'target-display',
|
19
|
-
'Choose the target display for results. Valid options are: stdout, prompt',
|
19
|
+
'Choose the target display for results. Valid options are: stdout, prompt, none',
|
20
20
|
argument: :required
|
21
21
|
end
|
22
22
|
|
23
23
|
def process(command)
|
24
24
|
case
|
25
25
|
when opts.version?
|
26
|
-
|
26
|
+
page <<-VERSION
|
27
|
+
#{bold('pry-auto_benching.rb')} #{bold("v#{Pry::AutoBenching::VERSION}")}
|
28
|
+
--
|
29
|
+
If you found a bug, have a suggestion or an improvement to make please open an
|
30
|
+
issue / pull request at https://github.com/r-obert/pry-auto_benching.rb
|
31
|
+
VERSION
|
27
32
|
when opts.t?
|
28
33
|
change_target_display(opts[:t])
|
29
34
|
when opts.past?
|
@@ -31,10 +36,10 @@ Pry::Commands.add_command Class.new(Pry::ClassCommand) {
|
|
31
36
|
else
|
32
37
|
if command == 'enable'
|
33
38
|
Pry::AutoBenching.enable(_pry_)
|
34
|
-
|
39
|
+
page('pry-auto_benching.rb: benchmarking.')
|
35
40
|
elsif command == 'disable'
|
36
41
|
Pry::AutoBenching.disable(_pry_)
|
37
|
-
|
42
|
+
page('pry-auto_benching.rb: stopped benchmarking.')
|
38
43
|
else
|
39
44
|
raise Pry::CommandError, "'#{command}' is not implemented by this command, try -h for help."
|
40
45
|
end
|
@@ -57,7 +62,7 @@ Pry::Commands.add_command Class.new(Pry::ClassCommand) {
|
|
57
62
|
end
|
58
63
|
|
59
64
|
def change_target_display(target_display)
|
60
|
-
if %w
|
65
|
+
if %w[prompt output none].include?(target_display)
|
61
66
|
_pry_.config.auto_benching.target_display = target_display
|
62
67
|
page "Display changed to '#{target_display}'"
|
63
68
|
else
|
@@ -68,4 +73,4 @@ Pry::Commands.add_command Class.new(Pry::ClassCommand) {
|
|
68
73
|
def page(str)
|
69
74
|
_pry_.pager.page str
|
70
75
|
end
|
71
|
-
}
|
76
|
+
}
|
data/lib/pry-auto_benching.rb
CHANGED
@@ -59,6 +59,8 @@ module Pry::AutoBenching
|
|
59
59
|
elsif target_display == 'output'
|
60
60
|
pry.config.forget(:prompt_name)
|
61
61
|
pry.pager.page auto_benching.output_string.call(pry, duration)
|
62
|
+
elsif target_display == 'none'
|
63
|
+
pry.config.forget(:prompt_name)
|
62
64
|
else
|
63
65
|
pry.config.forget(:prompt_name)
|
64
66
|
pry.output.warn "_pry_.config.auto_benching.target_display has an invalid value " \
|
data/pry-auto_benching.gemspec
CHANGED
@@ -4,7 +4,7 @@ Gem::Specification.new do |spec|
|
|
4
4
|
spec.version = Pry::AutoBenching::VERSION
|
5
5
|
spec.authors = ["Robert Gleeson"]
|
6
6
|
spec.email = "trebor.g@protonmail.com"
|
7
|
-
spec.summary = "
|
7
|
+
spec.summary = "Automates benchmarking in Pry"
|
8
8
|
spec.description = spec.summary
|
9
9
|
spec.homepage = "https://github.com/r-obert/pry-auto_benching.rb"
|
10
10
|
spec.licenses = ["MIT"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-auto_benching.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Gleeson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.12'
|
27
|
-
description:
|
27
|
+
description: Automates benchmarking in Pry
|
28
28
|
email: trebor.g@protonmail.com
|
29
29
|
executables: []
|
30
30
|
extensions: []
|
@@ -60,5 +60,5 @@ rubyforge_project:
|
|
60
60
|
rubygems_version: 2.7.7
|
61
61
|
signing_key:
|
62
62
|
specification_version: 4
|
63
|
-
summary:
|
63
|
+
summary: Automates benchmarking in Pry
|
64
64
|
test_files: []
|