cutter 0.8.8 → 0.8.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +35 -1
- data/lib/cutter/inspection.rb +1 -1
- data/lib/cutter/version.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -34,7 +34,7 @@ Insert ```#inspect!``` method into any of your methods:
|
|
34
34
|
def your_method *your_args
|
35
35
|
# ...
|
36
36
|
|
37
|
-
inspect! {} # curly braces are important!
|
37
|
+
inspect! {} # curly braces are important - they capture original environment!
|
38
38
|
|
39
39
|
# or
|
40
40
|
# iii {} as an alias
|
@@ -257,6 +257,40 @@ Demonstration of named stamping
|
|
257
257
|
1001ms
|
258
258
|
```
|
259
259
|
|
260
|
+
### Stamper with ```:capture => true``` option
|
261
|
+
|
262
|
+
Use it to hide the output of piece you are benchmarking.
|
263
|
+
|
264
|
+
```ruby
|
265
|
+
require 'cutter'
|
266
|
+
|
267
|
+
N = 100000
|
268
|
+
|
269
|
+
result = []
|
270
|
+
|
271
|
+
EMB = "String to embed"
|
272
|
+
|
273
|
+
result << stamper(:capture => true) do
|
274
|
+
N.times do
|
275
|
+
puts "#{EMB}\n"
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
result << stamper(:capture => true) do
|
280
|
+
N.times do
|
281
|
+
printf "#{EMB}\n"
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
result << stamper(:capture => true) do
|
286
|
+
N.times do
|
287
|
+
print "#{EMB}\n"
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
puts result.inspect
|
292
|
+
```
|
293
|
+
|
260
294
|
## Notes
|
261
295
|
|
262
296
|
* Both ```#inspect! {}``` and ```#stamper``` methods colorize their output. You can see ```lib/cutter/colored_output.rb``` file to understand how it is done. I will really appreciate any suggestions of how current color scheme can be improved.
|
data/lib/cutter/inspection.rb
CHANGED
@@ -44,7 +44,7 @@ class Object
|
|
44
44
|
method_name = eval('__method__', _binding)
|
45
45
|
class_name = eval('self.class', _binding)
|
46
46
|
|
47
|
-
if (meth = method(method_name.to_sym)).respond_to?
|
47
|
+
if method_name && (meth = method(method_name.to_sym)).respond_to?(:source_location)
|
48
48
|
source_path, source_number = meth.source_location
|
49
49
|
end
|
50
50
|
|
data/lib/cutter/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cutter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: colorize
|
@@ -107,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: '0'
|
108
108
|
segments:
|
109
109
|
- 0
|
110
|
-
hash:
|
110
|
+
hash: 2471605463323976295
|
111
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
112
|
none: false
|
113
113
|
requirements:
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
118
|
rubyforge_project:
|
119
|
-
rubygems_version: 1.8.
|
119
|
+
rubygems_version: 1.8.24
|
120
120
|
signing_key:
|
121
121
|
specification_version: 3
|
122
122
|
summary: Ruby tracing gem
|