pry-auto_benching.rb 2.5.0 → 2.6.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 +35 -13
- data/lib/pry-auto_benching/version.rb +1 -1
- data/lib/pry-auto_benching.rb +5 -2
- 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: 044da9140719553bfd2237e1ad32811a163a0b2674c51b95549943e442712be3
|
4
|
+
data.tar.gz: 63ac4fbd7ceb70b976092d2f076b3b9993a46039e10242e6cd47683fe40ca7c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9952b83e1eb104a6866814d534a8025e371002ea46e8b9e6f67ea03a8263baf29a62a290aea60a0a3982500664141fec65b2f01826e8ea802fe44a888baede9a
|
7
|
+
data.tar.gz: 8bdbe59fc8f36e04927f06977bdfc94b2570942ae3dedfa6126c7383872572f7a1c343928c6dc303e4d2473fdcfe23511f5375ffc91cfd935441ebc38dcac011
|
data/README.md
CHANGED
@@ -5,7 +5,8 @@ pry-auto_benching.rb automatically benchmarks input entered into Pry.
|
|
5
5
|
## Configuration (optional)
|
6
6
|
|
7
7
|
Configuration isn't required unless you want to change a default.
|
8
|
-
To change a default, open
|
8
|
+
To change a default, open `~/.pryrc` and add code along the lines
|
9
|
+
of:
|
9
10
|
|
10
11
|
```ruby
|
11
12
|
Pry.configure do |config|
|
@@ -46,31 +47,52 @@ __1.__
|
|
46
47
|
|
47
48
|
Show help by running `auto-benching -h`:
|
48
49
|
|
49
|
-
|
50
|
+
[3] pry(main)> auto-benching -h-h
|
51
|
+
Usage: auto-benching [enable|disable]
|
52
|
+
|
53
|
+
Enable or disable benchmarking code and Pry commands.
|
54
|
+
|
55
|
+
-v, --version Display version.
|
56
|
+
-h, --help Show this message.
|
50
57
|
|
51
58
|
__2.__
|
52
59
|
|
53
60
|
Disable auto benchmarking by running `auto-benching disable`:
|
54
61
|
|
55
|
-
|
62
|
+
[5] pry(main)> auto-benching disable
|
63
|
+
pry-auto_benching.rb: stopped benchmarking.
|
64
|
+
[6] pry(main)>
|
56
65
|
|
57
66
|
__3.__
|
58
67
|
|
59
|
-
A screenshot,
|
60
|
-
The prompt name (by default 'pry') is replaced with the benchmark results
|
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.
|
68
|
+
A screenshot, with `_pry_.config.auto_benching.target_display` set to `:prompt` (the default).
|
63
69
|
|
64
|
-
|
70
|
+
[7] pry(main)> sleep 0.2
|
71
|
+
=> 0
|
72
|
+
[8] 0.2s (main)> Net::HTTP.get_response URI.parse('https://github.com')
|
73
|
+
=> #<Net::HTTPOK 200 OK readbody=true>
|
74
|
+
[9] 1.34s (main)> Net::HTTP.get_response URI.parse('https://www.ruby-lang.org')
|
75
|
+
=> #<Net::HTTPOK 200 OK readbody=true>
|
76
|
+
[10] 1.53s (main)>
|
65
77
|
|
66
78
|
__4.__
|
67
79
|
|
68
|
-
A screenshot,
|
69
|
-
To switch to
|
70
|
-
inside the repl or set `Pry.config.auto_benching.target_display = :output` from your
|
71
|
-
for a permanent change.
|
80
|
+
A screenshot, with `_pry_.config.auto_benching.target_display` set to `:output`.
|
81
|
+
To switch to this display, run `_pry_.config.auto_benching.target_display = :output`
|
82
|
+
inside the repl or set `Pry.config.auto_benching.target_display = :output` from your
|
83
|
+
`.pryrc` for a permanent change.
|
72
84
|
|
73
|
-
|
85
|
+
[6] pry(main)> _pry_.config.auto_benching.target_display = :output
|
86
|
+
=> :output
|
87
|
+
[7] pry(main)> sleep 0.1
|
88
|
+
pry-auto_benching.rb: 0.10s
|
89
|
+
=> 0
|
90
|
+
[8] pry(main)> Net::HTTP.get_response URI.parse('https://github.com')
|
91
|
+
pry-auto_benching.rb: 0.85s
|
92
|
+
=> #<Net::HTTPOK 200 OK readbody=true>
|
93
|
+
[9] pry(main)> Net::HTTP.get_response URI.parse('https://www.ruby-lang.org')
|
94
|
+
pry-auto_benching.rb: 0.31s
|
95
|
+
=> #<Net::HTTPOK 200 OK readbody=true>
|
74
96
|
|
75
97
|
## Accuracy
|
76
98
|
|
data/lib/pry-auto_benching.rb
CHANGED
@@ -4,6 +4,7 @@ module Pry::AutoBenching
|
|
4
4
|
if auto_benching.target_display == :prompt
|
5
5
|
pry.config.prompt_name = Pry.lazy { "#{Pry::Helpers::Text.send(auto_benching.prompt_color, duration.to_s + 's')} " }
|
6
6
|
elsif auto_benching.target_display == :output
|
7
|
+
pry.config.prompt_name = Pry::Prompt::DEFAULT_NAME
|
7
8
|
pry.pager.page auto_benching.output_string.call(pry, duration)
|
8
9
|
else
|
9
10
|
pry.config.prompt_name = Pry::Prompt::DEFAULT_NAME
|
@@ -27,13 +28,15 @@ module Pry::AutoBenching
|
|
27
28
|
if auto_benching.benchmark_commands and
|
28
29
|
auto_benching.display_duration_if.call(pry, duration)
|
29
30
|
write_duration.call(pry, duration)
|
30
|
-
elsif auto_benching.target_display
|
31
|
+
elsif [:output, :prompt].include?(auto_benching.target_display) ||
|
32
|
+
auto_benching.target_display != :output
|
31
33
|
pry.config.prompt_name = Pry::Prompt::DEFAULT_NAME
|
32
34
|
end
|
33
35
|
else # Ruby code
|
34
36
|
if auto_benching.display_duration_if.call(pry, duration)
|
35
37
|
write_duration.call(pry, duration)
|
36
|
-
elsif auto_benching.target_display
|
38
|
+
elsif [:output, :prompt].include?(auto_benching.target_display) ||
|
39
|
+
auto_benching.target_display != :output
|
37
40
|
pry.config.prompt_name = Pry::Prompt::DEFAULT_NAME
|
38
41
|
end
|
39
42
|
end
|