benchmark_harness 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/benchmark_harness.gemspec +1 -1
- data/lib/benchmark_harness.rb +5 -4
- data/spec/benchmark_harness_spec.rb +6 -0
- data/spec/fixtures/nested_example.rb +5 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/benchmark_harness.gemspec
CHANGED
data/lib/benchmark_harness.rb
CHANGED
@@ -43,14 +43,15 @@ class BenchmarkHarness
|
|
43
43
|
else
|
44
44
|
raise ArgumentError, "your signature must contain a method"
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
constant_name, method_name = signature.split(split_on)
|
48
|
+
method_name_safe = method_name.gsub(/[\W\D]/, '') # trip out ie !
|
48
49
|
constant = get_constant(constant_name)
|
49
50
|
|
50
51
|
method_definition = <<-END
|
51
|
-
alias :#{
|
52
|
+
alias :#{method_name_safe}_pre_benchmark_harness :#{method_name}
|
52
53
|
def #{method_name}(*args, &block)
|
53
|
-
BenchmarkHarness.measure(:#{collection_name}){result = #{
|
54
|
+
BenchmarkHarness.measure(:#{collection_name}){result = #{method_name_safe}_pre_benchmark_harness(*args, &block)}
|
54
55
|
end
|
55
56
|
END
|
56
57
|
|
@@ -69,7 +70,7 @@ class BenchmarkHarness
|
|
69
70
|
if parent_constant.const_defined?(piece)
|
70
71
|
parent_constant = parent_constant.const_get(piece)
|
71
72
|
else
|
72
|
-
raise NameError, "#{name} contains an undefined constant"
|
73
|
+
raise NameError, "#{name} contains an undefined constant; it may be autoloaded"
|
73
74
|
end
|
74
75
|
end
|
75
76
|
parent_constant
|
@@ -95,6 +95,12 @@ describe "BenchmarkHarness" do
|
|
95
95
|
NestedExample::OneLevelDown.new.subtract
|
96
96
|
BenchmarkHarness.collections[:subtract].should_not be_empty
|
97
97
|
end
|
98
|
+
|
99
|
+
it "should wrap a method with an '!' in the name" do
|
100
|
+
BenchmarkHarness.wrap_method("NestedExample#important!", :important)
|
101
|
+
NestedExample.new.important!
|
102
|
+
BenchmarkHarness.collections[:important].should_not be_empty
|
103
|
+
end
|
98
104
|
end
|
99
105
|
|
100
106
|
describe "#flush" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: benchmark_harness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel Higginbotham
|