pry-auto_benching.rb 2.3.0 → 2.4.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 +38 -16
- data/lib/pry-auto_benching/version.rb +1 -1
- data/lib/pry-auto_benching.rb +2 -1
- 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: d17e07b5ba61c9f849c1a11b0987e4b0020e314ffed0e7ff5e805e411c040090
|
4
|
+
data.tar.gz: a4dad50eed12988b0f9dd89b8df46061a56d8723caace535af7875c2feaeb0a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7ab39a83c384f2c120e1549778bfcadd05730703cb7d66cf4f3dbf34a25f7747216f7be9b26d9a0220a59c721c7fcfe71ab40fb812a994209c125f88e987571
|
7
|
+
data.tar.gz: 689ea8ed86ce0d0d76f1927ee768f733ecab7b3cf8db6cddf149300cbfaad6ff000c0db9a60c267645a5b838c65b9c2362b0c8ee9d3d96c86b1dd3391c626de1
|
data/README.md
CHANGED
@@ -46,41 +46,63 @@ __1.__
|
|
46
46
|
|
47
47
|
Show help by running `auto-benching -h`:
|
48
48
|
|
49
|
-
|
50
|
-
Usage: auto-benching [enable|disable]
|
51
|
-
|
52
|
-
Enable or disable benchmarking of code and Pry commands.
|
53
|
-
|
54
|
-
-v, --version Display version.
|
55
|
-
-h, --help Show this message.
|
49
|
+

|
56
50
|
|
57
51
|
__2.__
|
58
52
|
|
59
53
|
Disable auto benchmarking by running `auto-benching disable`:
|
60
54
|
|
61
|
-
|
62
|
-
pry-auto_benching.rb: stopped benchmarking.
|
63
|
-
[2] pry(main)> sleep 2
|
64
|
-
=> 2
|
55
|
+

|
65
56
|
|
66
57
|
__3.__
|
67
58
|
|
68
59
|
A screenshot, using `:prompt` as the target_display.
|
69
60
|
The prompt name (by default 'pry') is replaced with the benchmark results
|
70
|
-
for the previous expression. This is the default since it is subtle,
|
71
|
-
easy to spot in a sea of output.
|
61
|
+
for the previous expression. This is the default target_display since it is subtle,
|
62
|
+
yet easy to spot in a sea of output.
|
72
63
|
|
73
|
-

|
74
65
|
|
75
66
|
__4.__
|
76
67
|
|
77
68
|
A screenshot, using `:output` as the target_display.
|
78
69
|
To switch to using this display, run `_pry_.config.auto_benching.target_display = :output`
|
79
|
-
inside the repl or set `Pry.config.auto_benching.target_display` from
|
80
|
-
permanent change.
|
70
|
+
inside the repl or set `Pry.config.auto_benching.target_display = :output` from your .pryrc
|
71
|
+
for a permanent change.
|
81
72
|
|
82
73
|

|
83
74
|
|
75
|
+
## Accuracy
|
76
|
+
|
77
|
+
pry-auto_benching.rb can measure down to a tenth of a millisecond (0.01 represents 10 milliseconds),
|
78
|
+
benchmarking `sleep 0.01` shows no overhead in the results:
|
79
|
+
|
80
|
+
[1] pry(main)> sleep 0.01
|
81
|
+
=> 0
|
82
|
+
[2] 0.01s (main)>
|
83
|
+
|
84
|
+
but it is possible results could be reported inaccurately since the measurement
|
85
|
+
includes a **very** small number of method calls to Pry internals. The overhead should be
|
86
|
+
minimal and skew results by a margin that could be considered negligible.
|
87
|
+
|
88
|
+
## Integration with custom prompts
|
89
|
+
|
90
|
+
If you want a custom prompt to integrate with pry-auto_benching.rb, it's easy, simply use
|
91
|
+
`pry.config.prompt_name` (by default it is equal to 'pry') somewhere in the prompt and the
|
92
|
+
duration of a benchmark will be inserted in its place.
|
93
|
+
|
94
|
+
Example:
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
Pry::Prompt.add(
|
98
|
+
:some_prompt,
|
99
|
+
'description of some_prompt',
|
100
|
+
%w[> *]
|
101
|
+
) do |target, nestlevel, pry, sep|
|
102
|
+
"#{pry.config.prompt_name}#{sep} "
|
103
|
+
end
|
104
|
+
```
|
105
|
+
|
84
106
|
## Install
|
85
107
|
|
86
108
|
gem install pry-auto_benching.rb
|
data/lib/pry-auto_benching.rb
CHANGED
@@ -7,7 +7,8 @@ module Pry::AutoBenching
|
|
7
7
|
pry.pager.page auto_benching.output_string.call(pry, duration)
|
8
8
|
else
|
9
9
|
pry.config.prompt_name = Pry::Prompt::DEFAULT_NAME
|
10
|
-
pry.output.warn "_pry_.config.auto_benching.target_display has an invalid value
|
10
|
+
pry.output.warn "_pry_.config.auto_benching.target_display has an invalid value " \
|
11
|
+
"(#{auto_benching.target_display.inspect}). \n" \
|
11
12
|
"It should be equal to ':output' or ':prompt'."
|
12
13
|
end
|
13
14
|
}
|