pry-auto_benching.rb 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c64613702b3a3a96336fac534cca684b78d8d2e433e38a6114c7176df3452e3
4
- data.tar.gz: 176537386876b1d80635529ce8e90f80a55846edb7e7ff1a541fcfd84a59bdb4
3
+ metadata.gz: d17e07b5ba61c9f849c1a11b0987e4b0020e314ffed0e7ff5e805e411c040090
4
+ data.tar.gz: a4dad50eed12988b0f9dd89b8df46061a56d8723caace535af7875c2feaeb0a6
5
5
  SHA512:
6
- metadata.gz: 5dcf41b8c27e1d208ef6dd026ed7bfb28054a8c355ebf638a53670f325c538797fb0d111071e0bcfa013d070bf5f0d2a73fb3ac85d579d388ff1cecea736143b
7
- data.tar.gz: de3a8d730752c69bc74f9fee10005655ead9b7e96723d36cc7b283adedf7c9321fa5541671ec555741e694eb6fde5b537b55d733d0cf248e1bc07ad4f9fb6e6e
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
- [1] pry(main)> auto-benching -h
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
+ ![s3](./s3.png)
56
50
 
57
51
  __2.__
58
52
 
59
53
  Disable auto benchmarking by running `auto-benching disable`:
60
54
 
61
- [1] pry(main)> auto-benching disable
62
- pry-auto_benching.rb: stopped benchmarking.
63
- [2] pry(main)> sleep 2
64
- => 2
55
+ ![s4](./s4.png)
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, yet
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
- ![s1](./s1.png)
64
+ ![s7](./s7.png)
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 your .pryrc for a
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
  ![s2](./s2.png)
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
@@ -1,5 +1,5 @@
1
1
  class Pry
2
2
  module AutoBenching
3
- VERSION = "2.3.0"
3
+ VERSION = "2.4.0"
4
4
  end
5
5
  end
@@ -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 (#{auto_benching.target_display.inspect}). \n" \
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
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry-auto_benching.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Gleeson