profiling 1.2.0 → 2.0.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 +9 -9
- data/lib/profiling/configuration.rb +3 -1
- data/lib/profiling/engine.rb +28 -3
- data/lib/profiling/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93ace3273f3436ce25c317fbad89c277548c9af4
|
4
|
+
data.tar.gz: 37ecc2ab961d454be1a4461af1728a815f830ea0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b820255232fea158d0d25184ae3597a4a73b664ce2df1a0b8bd520d5b28197c04134bd8a8d5eee0a8f6fe21b546a2c96821daf3e4f7e7ef0446865f49c7eab4
|
7
|
+
data.tar.gz: 7c5f38ac38441ff62a5f03a27d64cd04c662b67b00b98ba6928c8d52e8fe2ed56a3bba744da7b5d806dda475356a74e1c377ffcd41436d305701bb02809155dd
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ Non-discriminatory profiling for your MRI Ruby code. This gem is a small wrapper
|
|
12
12
|
Add this line to your application's Gemfile:
|
13
13
|
|
14
14
|
```ruby
|
15
|
-
gem 'profiling', "~> 1.
|
15
|
+
gem 'profiling', "~> 1.2"
|
16
16
|
```
|
17
17
|
|
18
18
|
And then execute:
|
@@ -51,15 +51,15 @@ The next time you call the code it will be profiled and three files will be writ
|
|
51
51
|
|
52
52
|
## Configuration
|
53
53
|
|
54
|
-
Change the directory the files will be generated in:
|
55
|
-
|
56
54
|
```ruby
|
57
55
|
Profiler.config = {
|
58
|
-
dir: '
|
56
|
+
dir: 'profiling', # Directory the files will be created in (default is 'profiling')
|
57
|
+
exclude_gems: true, # Exclude ruby gems from the results (default is true)
|
58
|
+
exclude_standard_lib: false # Exclude ruby standard library from results (default is false)
|
59
59
|
}
|
60
60
|
```
|
61
61
|
|
62
|
-
|
62
|
+
## Rails Initializer
|
63
63
|
|
64
64
|
This initializer is recommended if you're planning to profile in Rails:
|
65
65
|
|
@@ -72,7 +72,7 @@ Profiler.config = {
|
|
72
72
|
|
73
73
|
## Conditional Profiling
|
74
74
|
|
75
|
-
Pass an argument `if:` to enable or disable profiling:
|
75
|
+
Pass an argument `if:` to enable or disable profiling at run time:
|
76
76
|
|
77
77
|
```ruby
|
78
78
|
Profiler.run(if: user.is_admin?) do
|
@@ -82,7 +82,7 @@ end
|
|
82
82
|
|
83
83
|
## Preserving artefacts
|
84
84
|
|
85
|
-
Every time code is profiled the previous files will be overwritten unless the label
|
85
|
+
Every time code is profiled the previous files will be overwritten unless the label is dynamic. To keep old files, add the current time in the label so new files are generated with each run:
|
86
86
|
|
87
87
|
```ruby
|
88
88
|
Profiler.run("my-label-#{Time.now.to_i}") do
|
@@ -90,9 +90,9 @@ Profiler.run("my-label-#{Time.now.to_i}") do
|
|
90
90
|
end
|
91
91
|
```
|
92
92
|
|
93
|
-
|
93
|
+
## Organizing artefacts
|
94
94
|
|
95
|
-
Labels translate to directories, so use `/` in your labels to group
|
95
|
+
Labels translate to directories, so use `/` in your labels to group artefacts together:
|
96
96
|
|
97
97
|
```ruby
|
98
98
|
Profiler.run("post/create") do
|
data/lib/profiling/engine.rb
CHANGED
@@ -11,16 +11,41 @@ class Profiler
|
|
11
11
|
|
12
12
|
require 'ruby-prof'
|
13
13
|
|
14
|
-
RubyProf.
|
14
|
+
profile = RubyProf::Profile.new
|
15
|
+
|
16
|
+
profile.exclude_methods!(::Profiler::Engine, :run)
|
17
|
+
profile.exclude_common_methods! if config[:exclude_standard_lib]
|
18
|
+
# Note, we optionally exclude ruby gems after collecting the profile results
|
19
|
+
# instead of here as we can't exclude by a path any other way.
|
20
|
+
|
21
|
+
profile.start
|
15
22
|
|
16
23
|
begin
|
17
24
|
yield
|
18
25
|
rescue => e
|
19
|
-
|
26
|
+
profile.stop
|
20
27
|
raise e
|
21
28
|
end
|
22
29
|
|
23
|
-
@results =
|
30
|
+
@results = profile.stop
|
31
|
+
|
32
|
+
# Remove certain things from the profiling
|
33
|
+
unless @results.threads.empty?
|
34
|
+
exclude_paths = []
|
35
|
+
|
36
|
+
if config[:exclude_gems]
|
37
|
+
exclude_paths << /\/gems\//
|
38
|
+
end
|
39
|
+
|
40
|
+
unless exclude_paths.empty?
|
41
|
+
@results.threads.first.methods.each do |method|
|
42
|
+
if exclude_paths.any?{|regex| method.source_file.match(regex) }
|
43
|
+
method.eliminate!
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
24
49
|
out()
|
25
50
|
end
|
26
51
|
|
data/lib/profiling/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: profiling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Duncalfe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0.
|
103
|
+
version: '0.17'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0.
|
110
|
+
version: '0.17'
|
111
111
|
description: 'Non-discriminatory Ruby code profiling: This gem is a small wrapper
|
112
112
|
around the ruby-prof gem to do simple but powerful profiling'
|
113
113
|
email:
|