perforator 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +45 -0
- data/lib/perforator/version.rb +1 -1
- data/lib/perforator.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 765608fcc481e88b7621130998a320433e424f61
|
4
|
+
data.tar.gz: b4d0060e1a221516f3e4eec1263c5ea1da90d614
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52bbcde22a49ac34237cf3cfc401130f15cd1f6b94fda34ce21ece48c1cfde06c34030db01ce40fe5b52289cc5168fde415c632043cde79ddcdc36f7c0c1d4d1
|
7
|
+
data.tar.gz: 19460fd73bf0913ef060651f30afe8e32185a5e06432ecabd683baa0b693c96f48a6fff6f384cc820585075d8936fd1fc95c3e8e46cb9a81ea865b285cd4a609
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/sveredyuk/perforator.svg?branch=master)](https://travis-ci.org/sveredyuk/perforator)
|
2
|
+
|
1
3
|
# Perforator
|
2
4
|
|
3
5
|
### Simple and pretty stupid way to measure execution time of your code
|
@@ -50,6 +52,49 @@ my_meter = Perforator::Meter.new(
|
|
50
52
|
)
|
51
53
|
```
|
52
54
|
|
55
|
+
|
56
|
+
You can skip any option if you don't need it.
|
57
|
+
|
58
|
+
But for callbacks :expected_time is necessary:
|
59
|
+
```ruby
|
60
|
+
Perforator::Meter.new(positive_callback: -> { puts ':)' }) #=> NoExpectedTimeError
|
61
|
+
```
|
62
|
+
|
63
|
+
Callbacks must be callable:
|
64
|
+
```ruby
|
65
|
+
Perforator::Meter.new(positive_callback: Hash.new) #=> NotCallableCallbackError
|
66
|
+
|
67
|
+
```
|
68
|
+
|
69
|
+
Expeted time must be fixnum:
|
70
|
+
```ruby
|
71
|
+
Perforator::Meter.new(expected_time: '10') #=> NotFixnumExpectedTimeError
|
72
|
+
|
73
|
+
```
|
74
|
+
|
75
|
+
Just wrap your code with meter:
|
76
|
+
```ruby
|
77
|
+
my_meter.call do
|
78
|
+
# put your code here
|
79
|
+
end
|
80
|
+
```
|
81
|
+
|
82
|
+
Any of undefined method for meter will be added to output and log. It helps to add some custom breakpoints:
|
83
|
+
```ruby
|
84
|
+
my_meter.call do |meter|
|
85
|
+
meter.some_start 'Value'
|
86
|
+
# put your code here
|
87
|
+
meter.some_finish 'Valud'
|
88
|
+
end
|
89
|
+
|
90
|
+
# =======> your label
|
91
|
+
# some_start: Value
|
92
|
+
# Start: 2017-06-02 14:24:53 +0300
|
93
|
+
# Finish: 2017-06-02 14:24:54 +0300
|
94
|
+
# Spent: 1.000919
|
95
|
+
# some_finish Value
|
96
|
+
```
|
97
|
+
|
53
98
|
## Development
|
54
99
|
|
55
100
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/perforator/version.rb
CHANGED
data/lib/perforator.rb
CHANGED
@@ -88,8 +88,8 @@ module Perforator
|
|
88
88
|
end
|
89
89
|
|
90
90
|
# TODO Add possibility to log method_missing keys
|
91
|
-
|
92
|
-
|
93
|
-
|
91
|
+
def method_missing(meth, *args, &blk)
|
92
|
+
log!("#{meth}: #{args[0]}")
|
93
|
+
end
|
94
94
|
end
|
95
95
|
end
|