yard-bench 0.0.2 → 0.0.3

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
  !binary "U0hBMQ==":
3
- metadata.gz: f4b741f7ac917188402ae134a53b8ee9f65a4409
4
- data.tar.gz: a6db99b9f15facdd66aabd7936176681a0259caa
3
+ metadata.gz: 9e8567b9d6ef87a15a4c3c01bd809a9bae49e42c
4
+ data.tar.gz: 79aafe9d2e453c7838c53a65b7912834d2791f21
5
5
  !binary "U0hBNTEy":
6
- metadata.gz: 4c3359d6aaf319af83c779c4998aa438f5ed846b69335a6b6a1082e3eb19450f30cf9f6e2b237cb11d3b004d44f77facc265132ffc54775b2c63e02dc228a894
7
- data.tar.gz: 22637cfe552421e8bf4d11bb1fd1817a84b27fe7ad2568eb1b6dfc7d589680322935b8e4e7ad1cba61da41b857454afc3330388db48b87b3dd16d94fb8d1a3af
6
+ metadata.gz: 50999cac89d2fa786c7f852e858620328f7ffec57ee4e21f46e18665e79d55230f7a3ef7b6240043dfc1eda42b79842841bf9e3c7904bd6a26e2c19a5787c5e7
7
+ data.tar.gz: cc4396f9a4af167123ab2f046ecdb7b0014c4c3e71cc41faedf5ab321687f147fe6bc53da2686bc0007d4ba864c5e2129f90ccb29cdac5648b10e2f214ca135e
data/README.md CHANGED
@@ -1,6 +1,81 @@
1
1
  # YARD::Bench
2
2
 
3
- TODO: Write a gem description
3
+ Lazy benchmarking of your project, which appears in the generated [YARD](http://yardoc.org/) documentation.
4
+ There is a handy DSL provided to make benchmarking almost without additional effort.
5
+
6
+ To mark a method(s) for benchmarking, just put
7
+
8
+ ```ruby
9
+ benchmark :meth1, :meth2
10
+ ```
11
+
12
+ or
13
+
14
+ ⌚ :meth1, :meth2
15
+
16
+ or even
17
+
18
+ ```ruby
19
+ benchmark :⋅
20
+ ```
21
+
22
+ somewhere inside your class declaration. The latter states for benchmarking all the instance methods,
23
+ defined in the class. There are four wildcards available:
24
+
25
+ * `:⋅`  — benchmark instance methods of a class;
26
+ * `:⋅⋅` — benchmark instance methods of a class and all the superclasses;
27
+ * `:×`  — benchmark class methods of a class;
28
+ * `:××` — benchmark class methods of a class and all the superclasses;
29
+
30
+ Let’s say there is a class `BmExample` that you want to benchmark:
31
+
32
+ ```ruby
33
+ # Example module to test benchmarking functionality.
34
+ module BmExamples
35
+ # Example class to test benchmarking functionality.
36
+ class BmExample
37
+ benchmark :do_it
38
+ ⌚ :do_other
39
+
40
+ # The value
41
+ attr_reader :value
42
+ # Constructor.
43
+ # @param value [Fixnum] the value to add to 10 within {#value} initializer.
44
+ # @param addval [Fixnum] another value to add to 10 within {#value} initializer.
45
+ # @param attrs [Hash] additional parameters (ignored.)
46
+ def initialize value, addval, *attrs
47
+ @value = 10 + value + addval
48
+ end
49
+ # Multiplies {#value} by parameter given.
50
+ # @param deg [Fixnum]
51
+ # @return [Fixnum] {#value} multiplied by deg.
52
+ def do_it deg
53
+ @value * deg
54
+ end
55
+ # Produces a power of the parameter given.
56
+ # @param base [Fixnum]
57
+ # @return [Fixnum] {#value} in a power of base
58
+ def do_other base = 2
59
+ @value ** base
60
+ end
61
+ end
62
+ end
63
+ ```
64
+
65
+ The fifth and sixth lines of code will mark methods `do_it` and `do_other` for benchmarking.
66
+ Actual benchmarking will take place during yard documentation production. This definitely will
67
+ slow up the documentation generation, but in the production environment these do not
68
+ interfere the normal execution timeline at all.
69
+
70
+ After the generation is done, the methods are measured with an intellectual algorhytm:
71
+
72
+ ![YARD bench results](http://rocket-science.ru/img/yard-bench-result.png)
73
+
74
+ The results are 〈almost〉 independent of the architecture of the target machine on which
75
+ the measurements were done (they are normalized by `1_000_000.times {"foo bar baz".capitalize}`.)
76
+ There are meaningful values for amounts of times to test chosen (three results, having
77
+ significant figures in hundredth part.) The algorythm calculates the deviation of results and
78
+ suggests `O(N)` power of function timing, whether possible.
4
79
 
5
80
  ## Installation
6
81
 
@@ -20,12 +95,16 @@ Or install it yourself as:
20
95
 
21
96
  Put the following code anywhere within your class:
22
97
 
23
- benchmark :func1, :func2
98
+ ```ruby
99
+ benchmark :func1, :func2
100
+ ```
24
101
 
25
102
  or even:
26
103
 
27
- class String
28
- ⌚ :⋅
104
+ ```ruby
105
+ class String
106
+ ⌚ :⋅
107
+ ```
29
108
 
30
109
  and the benchmarks for the chosen functions will be included in yardoc.
31
110
 
@@ -2,6 +2,6 @@ require 'yard'
2
2
 
3
3
  module YARD
4
4
  module Bench
5
- VERSION = "0.0.2"
5
+ VERSION = "0.0.3"
6
6
  end
7
7
  end
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.description = %Q{YARD plugin, which adds a benchmarking results to YARDoc}
15
15
  s.extra_rdoc_files = [
16
16
  'LICENSE',
17
- 'README.md',
17
+ 'README.md'
18
18
  ]
19
19
 
20
20
  s.required_rubygems_version = Gem::Requirement.new('>= 1.3.7')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yard-bench
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexei Matyushkin