kantox-chronoscope 0.2.2 → 0.3.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
  SHA1:
3
- metadata.gz: a4d53501fb7342dcf28242a948af1251633b0383
4
- data.tar.gz: a2da48b18c3ad4ca31c7e82d2672bb1d93d631c8
3
+ metadata.gz: dff7a5c13087692f056fa3a698fdad64e0fdef46
4
+ data.tar.gz: 40805caadefc8ba3a6efc38757e57d5b26c1217c
5
5
  SHA512:
6
- metadata.gz: 09cec413684352711afc0f92055bc45a56c97d8224e2649d4235c538e0964e1eff9828d3fc55cafec069288072060c4e00c7c3e15747f1e614f31fee0121b27a
7
- data.tar.gz: 4b5dc5de71c87957b684954e58dc5c0bcab5826034c2692c597317417fa20b074a536a2b0bfbbe741af6e3b49faf900cc6f36cffc62f2449824de20bb37417aa
6
+ metadata.gz: 58fc0f60e486c203d7a4d36b17353e3273488d1be0e662f263fc13bada67b42941d21bf8e817c19bfb1a571812635f151f9249ae0cf7437ffaedf510445695ac
7
+ data.tar.gz: 27f91cdf5ffae2b81f6699b0f5c560c85f414f98b11f4fed1c23938d2a74bec5db242106d7cba6ad56433631f2ec0a4658b07147a62e2a3c34b0e3d4c3de5f02
data/README.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/am-kantox/kantox-chronoscope.svg?branch=master)](https://travis-ci.org/am-kantox/kantox-chronoscope)
4
4
 
5
+ `Chronoscope` is designed for those, who has not enough foresight and starts
6
+ benchmarking/profiling their applications when everything already is terrible.
7
+
8
+ On the other hand, `Chronoscope` is a lightweight solution, that permits
9
+ to plug in benchmarks for virtually everything in a matter of seconds.
10
+
11
+ It just works out of the box: no modifications of application code is required.
12
+ It permits benchmarking in production as well, though it is not recommended. The
13
+ total impact on productivity is proven to be less that 1%.
14
+
5
15
  ## Installation
6
16
 
7
17
  Add this line to your application's Gemfile:
@@ -20,7 +30,56 @@ Or install it yourself as:
20
30
 
21
31
  ## Usage
22
32
 
23
- TODO: Write usage instructions here
33
+ 1. Create the configuration file in `config/chronoscope.yml`:
34
+
35
+ ```yaml
36
+ general:
37
+ handler: 'Kantox::Chronoscope::Generic'
38
+ enable: true
39
+
40
+ options:
41
+ silent: true
42
+
43
+ i18n:
44
+ name: метод
45
+ times: раз
46
+ average: среднее
47
+ total: всего
48
+ ```
49
+
50
+ 2. Attach `Chronoscope` to one or more targets:
51
+
52
+ ```ruby
53
+ Kantox::Chronoscope.attach(Order) # all methods of Order
54
+ Kantox::Chronoscope.attach(User, :login) # User#login
55
+ ```
56
+
57
+ And somewhere in the execution end (e. g. when used with `Rails`, this goes into
58
+ `spec/spec_helper.rb`):
59
+
60
+ ```ruby
61
+ config.after(:suite) do
62
+ benchmarks = ⌛(cleanup: true)
63
+ end
64
+ ```
65
+
66
+ 3. Get the following output:
67
+
68
+ ![Chronoscope log](screenshot.jpg)
69
+
70
+ Here `silent` options is set to `false`, that’s why we see logs from each subsequent
71
+ call to monitored function.
72
+
73
+ 4. After execution, the result tree (with call hierarchy) is returned as:
74
+
75
+ ```ruby
76
+ puts '—'*($stdin.winsize.last rescue 80)
77
+ puts benchmarks[:data].inspect
78
+ puts '—'*($stdin.winsize.last rescue 80)
79
+ #⇒ {"Hedge#send_email_on_create"=>{:count=>26, :total=>0.00013026800000000003, :stack=>[]},
80
+ # "Hedge#send_email_on_create="=>{:count=>11, :total=>4.066e-05, :stack=>[]},
81
+ # "Hedge#hedge_type"=>{:count=>188, :total=>0.0024204860000000003, :stack=>[]} ...
82
+ ```
24
83
 
25
84
  ## Development
26
85
 
@@ -2,6 +2,9 @@ general:
2
2
  handler: 'Kantox::Chronoscope::Generic'
3
3
  enable: true
4
4
 
5
+ options:
6
+ silent: true
7
+
5
8
  i18n:
6
9
  name: метод
7
10
  times: раз
@@ -56,11 +56,12 @@ module Kantox
56
56
  next if (klazz.instance_method(m).parameters.to_h[:block] rescue false) # FIXME: report
57
57
 
58
58
  receiver, arg_string = m.to_s.end_with?('=') ? ['self.', 'arg'] : [nil, '*args'] # to satisfy setter
59
+ do_log = !option(ENV, 'options.silent')
59
60
 
60
61
  klazz.class_eval %Q|
61
62
  alias_method :'#{CHAIN_PREFIX}#{m}', :'#{m}'
62
63
  def #{m}(#{arg_string})
63
- ⌚('#{klazz}##{m}', #{Kantox::Chronoscope.config.options!.silent && false || true}) { #{receiver}#{CHAIN_PREFIX}#{m} #{arg_string} }
64
+ ⌚('#{klazz}##{m}', #{do_log}) { #{receiver}#{CHAIN_PREFIX}#{m} #{arg_string} }
64
65
  end
65
66
  |
66
67
  end
@@ -1,5 +1,5 @@
1
1
  module Kantox
2
2
  module Chronoscope
3
- VERSION = "0.2.2"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kantox-chronoscope
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kantox
@@ -121,6 +121,7 @@ files:
121
121
  - lib/kantox/chronoscope/dummy.rb
122
122
  - lib/kantox/chronoscope/generic.rb
123
123
  - lib/kantox/chronoscope/version.rb
124
+ - screenshot.jpg
124
125
  homepage: https://github.com/am-kantox/kantox-chronoscope
125
126
  licenses:
126
127
  - MIT