test-prof 0.1.0.beta4 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4bebeb0abae778ec18d0ec11538784b0255bd26d
4
- data.tar.gz: '098fa4a951eba03ac7fcda3e6565ca01936dd182'
3
+ metadata.gz: 29df0c008d08c25f6924b35fd76cf02e7747c116
4
+ data.tar.gz: 1216e9ee73060c8d20e2caa94b2d1fd5f9c70292
5
5
  SHA512:
6
- metadata.gz: 1099d6a1805f71697cccbb555025bffba6589e87016e33d715a046368e20dda1d5d1b2df259792b144c2ba0e7f816f64e6dd745f14114b1bb4ee6446e2edbba2
7
- data.tar.gz: 4212b16b0487b6a5c4853e855a07278778cc487f0b378148d4903e180d20a935e3110542bdaf553070f499ddce220a046366b2b18049ae598b6dc36e4a54e0dc
6
+ metadata.gz: d0b7e7e899c7a81512d686e4bfac89937f8c37df476ffc94daf7e351476b131c6301c8528731e263fc36a4c1397be5876fc053cf837cb51777a2dcb5ae1687f5
7
+ data.tar.gz: 143c0eb3c07ecbad124299395e06bc4174bda227a5ec36c4e71eb5c8d67eb6079e7f62a138c24da98d6dbc1c887529bf8105dc3c2e46b4df1cd4bbd06a65144b
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Gem Version](https://badge.fury.io/rb/test-prof.svg)](https://rubygems.org/gems/test-prof) [![Build Status](https://travis-ci.org/palkan/test-prof.svg?branch=master)](https://travis-ci.org/palkan/test-prof) [![Circle CI](https://circleci.com/gh/palkan/test-prof/tree/master.svg?style=svg)](https://circleci.com/gh/palkan/test-prof/tree/master)
1
+ [![Gem Version](https://badge.fury.io/rb/test-prof.svg)](https://rubygems.org/gems/test-prof) [![Build Status](https://travis-ci.org/palkan/test-prof.svg?branch=master)](https://travis-ci.org/palkan/test-prof) [![CircleCI](https://circleci.com/gh/palkan/test-prof.svg?style=svg)](https://circleci.com/gh/palkan/test-prof)
2
2
 
3
3
  # Ruby Tests Profiling Toolbox
4
4
 
@@ -53,7 +53,7 @@ Checkout our guides for each specific tool:
53
53
 
54
54
  - [StackProf Integration](https://github.com/palkan/test-prof/tree/master/guides/stack_prof.md)
55
55
 
56
- - [Instrumentation Profiler](https://github.com/palkan/test-prof/tree/master/guides/event_prof.md) (e.g. ActiveSupport notifications)
56
+ - [Event Profiler](https://github.com/palkan/test-prof/tree/master/guides/event_prof.md) (e.g. ActiveSupport notifications)
57
57
 
58
58
  - [Tag Profiler](https://github.com/palkan/test-prof/tree/master/guides/tag_prof.md)
59
59
 
data/guides/event_prof.md CHANGED
@@ -64,6 +64,36 @@ EVENT_PROF_RANK=count EVENT_PROF='instantiation.active_record' be rspec
64
64
 
65
65
  See [event_prof.rb](https://github.com/palkan/test-prof/tree/master/lib/test_prof/event_prof.rb) for all available configuration options and their usage.
66
66
 
67
+ ## Custom Instrumentation
68
+
69
+ To use EventProf with your instrumentation engine just complete the two following steps:
70
+
71
+ - Add a wrapper for your instrumentation:
72
+
73
+
74
+ ```ruby
75
+ # Wrapper over your instrumentation
76
+ module MyEventsWrapper
77
+ # Should contain the only one method
78
+ def self.subscribe(event)
79
+ raise ArgumentError, 'Block is required!' unless block_given?
80
+
81
+ ::MyEvents.subscribe(event) do |start, finish, *|
82
+ yield (finish - start)
83
+ end
84
+ end
85
+ end
86
+ ```
87
+
88
+ - Set instrumenter in the config:
89
+
90
+
91
+ ```ruby
92
+ TestProf::EventProf.configure do |config|
93
+ config.instrumenter = MyEventsWrapper
94
+ end
95
+ ```
96
+
67
97
  ## Custom Events
68
98
 
69
99
  ### `"factory.create"`
@@ -49,8 +49,8 @@ module TestProf
49
49
 
50
50
  msgs << ""
51
51
 
52
- total = @tags.values.sum { |v| v[:count] }
53
- total_time = @tags.values.sum { |v| v[:time] }
52
+ total = @tags.values.inject(0) { |acc, v| acc + v[:count] }
53
+ total_time = @tags.values.inject(0) { |acc, v| acc + v[:time] }
54
54
 
55
55
  @tags.values.sort_by { |v| -v[:time] }.each do |tag|
56
56
  msgs << format(
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TestProf
4
- VERSION = "0.1.0.beta4"
4
+ VERSION = "0.1.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-prof
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.beta4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-01 00:00:00.000000000 Z
11
+ date: 2017-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -236,12 +236,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
236
236
  requirements:
237
237
  - - ">="
238
238
  - !ruby/object:Gem::Version
239
- version: '0'
239
+ version: 2.3.0
240
240
  required_rubygems_version: !ruby/object:Gem::Requirement
241
241
  requirements:
242
- - - ">"
242
+ - - ">="
243
243
  - !ruby/object:Gem::Version
244
- version: 1.3.1
244
+ version: '0'
245
245
  requirements: []
246
246
  rubyforge_project:
247
247
  rubygems_version: 2.6.11