require_prof 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 +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +113 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/require_prof.rb +75 -0
- data/lib/require_prof/ext/kernel.rb +3 -0
- data/lib/require_prof/memory_sampler.rb +73 -0
- data/lib/require_prof/printers/abstract_printer.rb +21 -0
- data/lib/require_prof/printers/table_printer.rb +54 -0
- data/lib/require_prof/printers/tree_printer.rb +30 -0
- data/lib/require_prof/profile.rb +86 -0
- data/lib/require_prof/require_tree.rb +53 -0
- data/lib/require_prof/version.rb +3 -0
- data/require_prof.gemspec +26 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4c49d5f40de6332ebf834df091f6de815a0492d2
|
4
|
+
data.tar.gz: 1a906e1493fd0938e367360968739a70a259f8c4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 75a4bc193b559d49bac6998dbc0866915985f40f519882bb286a16c55c05e1b1c17670d2189af2194566410252ed1550c42c0a5380f2976e19e408fc06693a6f
|
7
|
+
data.tar.gz: 213695ef0e1d775d41c96e24766964bd89df1731aa6f29178290ec4c548f8d77b3168b5887e196e5ad15c7c4a16b1f581ba46a341f042867b4a9c7744307b07e
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Kirill Nikitin
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
# RequireProf
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'require_prof'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install require_prof
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
RequireProf profile some require like
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
result = RequireProf.profile do
|
25
|
+
require 'mime-types'
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
29
|
+
or just using start/stop without block
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
RequireProf.start
|
33
|
+
require 'mime-types'
|
34
|
+
result = RequireProf.stop
|
35
|
+
```
|
36
|
+
|
37
|
+
### Printers
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
printer = RequireProf::TreePrinter.new(result)
|
41
|
+
printer.print
|
42
|
+
# or with extra options
|
43
|
+
printer.print(output: STDOUT, precision: 3)
|
44
|
+
```
|
45
|
+
|
46
|
+
|
47
|
+
```
|
48
|
+
.
|
49
|
+
└── mime-types (136.68 ms, 13172 kb)
|
50
|
+
└── mime/types (132.64 ms, 13172 kb)
|
51
|
+
├── mime/type (9.84 ms, 408 kb)
|
52
|
+
│ ├── mime (0.4 ms, 0 kb)
|
53
|
+
│ └── json (6.12 ms, 408 kb)
|
54
|
+
│ ├── json/common (3.28 ms, 0 kb)
|
55
|
+
│ │ ├── json/version (0.23 ms, 0 kb)
|
56
|
+
│ │ └── json/generic_object (1.22 ms, 0 kb)
|
57
|
+
│ │ └── ostruct (0.78 ms, 0 kb)
|
58
|
+
│ ├── json/version (0.04 ms, 0 kb)
|
59
|
+
│ └── json/ext (2.09 ms, 408 kb)
|
60
|
+
│ ├── json/common (0.02 ms, 0 kb)
|
61
|
+
│ ├── json/ext/parser (0.92 ms, 112 kb)
|
62
|
+
│ └── json/ext/generator (0.41 ms, 32 kb)
|
63
|
+
├── mime/types/cache (0.69 ms, 0 kb)
|
64
|
+
├── mime/types/loader (1.31 ms, 0 kb)
|
65
|
+
│ └── mime/types/loader_path (0.2 ms, 0 kb)
|
66
|
+
└── json (0.02 ms, 0 kb)
|
67
|
+
```
|
68
|
+
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
printer = RequireProf::TablePrinter.new(result)
|
72
|
+
printer.print
|
73
|
+
# or with extra options
|
74
|
+
printer.print(output: STDOUT, sort: :memory, precision: 1, threshold: 100)
|
75
|
+
printer.print(output: STDOUT, sort: :time, precision: 3, threshold: 5)
|
76
|
+
```
|
77
|
+
|
78
|
+
|
79
|
+
```
|
80
|
+
+------------------------+-----------+-------------+
|
81
|
+
| name | time (ms) | memory (kb) |
|
82
|
+
+------------------------+-----------+-------------+
|
83
|
+
| mime/types | 105.92 | 13304.0 |
|
84
|
+
| mime-types | 3.94 | 0.0 |
|
85
|
+
| mime/type | 3.02 | 260.0 |
|
86
|
+
| json/common | 1.8 | 0.0 |
|
87
|
+
| mime/types/loader | 1.02 | 0.0 |
|
88
|
+
| json/ext | 0.93 | 0.0 |
|
89
|
+
| json/ext/parser | 0.86 | 248.0 |
|
90
|
+
| ostruct | 0.85 | 0.0 |
|
91
|
+
| json | 0.58 | 0.0 |
|
92
|
+
| mime/types/cache | 0.51 | 0.0 |
|
93
|
+
| json/generic_object | 0.46 | 0.0 |
|
94
|
+
| json/ext/generator | 0.37 | 32.0 |
|
95
|
+
| mime | 0.32 | 0.0 |
|
96
|
+
| json/version | 0.21 | 0.0 |
|
97
|
+
| mime/types/loader_path | 0.17 | 0.0 |
|
98
|
+
+------------------------+-----------+-------------+
|
99
|
+
```
|
100
|
+
|
101
|
+
## Development
|
102
|
+
|
103
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
104
|
+
|
105
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
106
|
+
|
107
|
+
## Contributing
|
108
|
+
|
109
|
+
1. Fork it ( https://github.com/Locke23rus/require_prof/fork )
|
110
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
111
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
112
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
113
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "require_prof"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/require_prof.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'require_prof/ext/kernel'
|
2
|
+
require 'require_prof/profile'
|
3
|
+
require 'require_prof/printers/tree_printer'
|
4
|
+
require 'require_prof/printers/table_printer'
|
5
|
+
require 'require_prof/version'
|
6
|
+
|
7
|
+
module RequireProf
|
8
|
+
|
9
|
+
def self.start
|
10
|
+
ensure_not_running!
|
11
|
+
@profile = Profile.new
|
12
|
+
@profile.start
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.pause
|
16
|
+
ensure_running!
|
17
|
+
@profile.pause
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.running?
|
21
|
+
if defined?(@profile) and @profile
|
22
|
+
@profile.running?
|
23
|
+
else
|
24
|
+
false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.paused?
|
29
|
+
if defined?(@profile) and @profile
|
30
|
+
@profile.paused?
|
31
|
+
else
|
32
|
+
false
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.resume
|
37
|
+
ensure_running!
|
38
|
+
@profile.resume
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.stop
|
42
|
+
ensure_running!
|
43
|
+
result = @profile.stop
|
44
|
+
@profile = nil
|
45
|
+
result
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.profile(&block)
|
49
|
+
unless block_given?
|
50
|
+
raise(ArgumentError, 'A block must be provided to the profile');
|
51
|
+
end
|
52
|
+
|
53
|
+
start
|
54
|
+
yield
|
55
|
+
stop
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.require(name)
|
59
|
+
if running? && !paused?
|
60
|
+
@profile.require(name)
|
61
|
+
else
|
62
|
+
rp_original_require(name)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def self.ensure_running!
|
69
|
+
raise 'RequireProf.start was not yet called' unless running?
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.ensure_not_running!
|
73
|
+
raise 'RequireProf.start was already called' if running?
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module RequireProf
|
2
|
+
class MemorySampler
|
3
|
+
|
4
|
+
def self.available?
|
5
|
+
return @available if defined?(@available)
|
6
|
+
@available = defined?(JRuby) || platform =~ /linux|darwin|freebsd|solaris/
|
7
|
+
unless @available
|
8
|
+
STDERR.puts "WARNING: Unsupported platform for getting memory '#{platform}'"
|
9
|
+
end
|
10
|
+
@available
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.sampler
|
14
|
+
return @sampler if defined?(@sampler)
|
15
|
+
|
16
|
+
@sampler = if defined? JRuby
|
17
|
+
JavaHeapSampler.new
|
18
|
+
elsif platform =~ /linux/
|
19
|
+
ProcStatus.new
|
20
|
+
# ShellPS.new('ps -o rsz')
|
21
|
+
elsif platform =~ /darwin9/ # 10.5
|
22
|
+
ShellPS.new('ps -o rsz')
|
23
|
+
elsif platform =~ /darwin1\d+/ # >= 10.6
|
24
|
+
ShellPS.new('ps -o rss')
|
25
|
+
elsif platform =~ /freebsd/
|
26
|
+
ShellPS.new('ps -o rss')
|
27
|
+
elsif platform =~ /solaris/
|
28
|
+
ShellPS.new('/usr/bin/ps -o rss -p')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.platform
|
33
|
+
if RUBY_PLATFORM =~ /java/
|
34
|
+
%x[uname -s].downcase
|
35
|
+
else
|
36
|
+
RUBY_PLATFORM.downcase
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.memory_usage
|
41
|
+
sampler.memory_usage
|
42
|
+
end
|
43
|
+
|
44
|
+
class JavaHeapSampler
|
45
|
+
def memory_usage
|
46
|
+
raise "Can't sample Java heap unless running in JRuby" unless defined? JRuby
|
47
|
+
java.lang.Runtime.getRuntime.totalMemory / 1024.0 rescue 0.0
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class ShellPS
|
52
|
+
def initialize(command)
|
53
|
+
@command = command
|
54
|
+
end
|
55
|
+
|
56
|
+
def memory_usage
|
57
|
+
process = $$
|
58
|
+
`#{@command} #{process}`.split("\n")[1].to_f rescue 0.0
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
class ProcStatus
|
63
|
+
def memory_usage
|
64
|
+
proc_status = File.open("/proc/#{$$}/status", 'r') { |f| f.read_nonblock(4096).strip }
|
65
|
+
if proc_status =~ /RSS:\s*(\d+) kB/i
|
66
|
+
$1.to_f
|
67
|
+
else
|
68
|
+
0.0
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module RequireProf
|
2
|
+
class AbstractPrinter
|
3
|
+
|
4
|
+
def initialize(result)
|
5
|
+
@result = result
|
6
|
+
end
|
7
|
+
|
8
|
+
def print(options = {})
|
9
|
+
@options = options
|
10
|
+
@output = options.fetch(:output, STDOUT)
|
11
|
+
print_result
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def precision
|
17
|
+
@options[:precision] || 2
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'set'
|
4
|
+
require 'require_prof/printers/abstract_printer'
|
5
|
+
require 'text-table'
|
6
|
+
|
7
|
+
|
8
|
+
module RequireProf
|
9
|
+
class TablePrinter < AbstractPrinter
|
10
|
+
SORTABLE_COLUMNS = %w(time memory)
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def print_result
|
15
|
+
process_result
|
16
|
+
print_table
|
17
|
+
end
|
18
|
+
|
19
|
+
def process_result
|
20
|
+
@processed_nodes = Set.new
|
21
|
+
@rows = []
|
22
|
+
process_nodes @result.children
|
23
|
+
end
|
24
|
+
|
25
|
+
def print_table
|
26
|
+
@output << Text::Table.new(head: ["name", "time (ms)", "memory (kb)"], rows: sorted_rows).to_s
|
27
|
+
end
|
28
|
+
|
29
|
+
def process_nodes(nodes)
|
30
|
+
nodes.each do |node|
|
31
|
+
unless @processed_nodes.include?(node.name)
|
32
|
+
@processed_nodes.add node.name
|
33
|
+
@rows << [node.name, node.time.round(precision), node.memory]
|
34
|
+
process_nodes node.children
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def sorted_rows
|
40
|
+
column = SORTABLE_COLUMNS.index(sort) + 1
|
41
|
+
@rows.select { |i| i[column] > threshold}.sort_by { |i| i[column] }.reverse
|
42
|
+
end
|
43
|
+
|
44
|
+
def sort
|
45
|
+
column = @options[:sort].to_s
|
46
|
+
SORTABLE_COLUMNS.include?(column) ? column : 'time'
|
47
|
+
end
|
48
|
+
|
49
|
+
def threshold
|
50
|
+
@options[:threshold] || 0.0
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'require_prof/printers/abstract_printer'
|
4
|
+
|
5
|
+
module RequireProf
|
6
|
+
class TreePrinter < AbstractPrinter
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def print_result
|
11
|
+
@output << "#{@result.name}\n"
|
12
|
+
print_trees(@result.children)
|
13
|
+
end
|
14
|
+
|
15
|
+
def print_trees(nodes, prefix = '')
|
16
|
+
last = nodes.size - 1
|
17
|
+
nodes.each_with_index do |node, i|
|
18
|
+
info = "#{node.name} (#{node.total_time.round(precision)} ms, #{node.total_memory.round} kb)\n"
|
19
|
+
if i == last
|
20
|
+
@output << "#{prefix}└── #{info}"
|
21
|
+
print_trees(node.children, prefix + ' ')
|
22
|
+
else
|
23
|
+
@output << "#{prefix}├── #{info}"
|
24
|
+
print_trees(node.children, prefix + '│ ')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'require_prof/ext/kernel'
|
2
|
+
require 'require_prof/memory_sampler'
|
3
|
+
require 'require_prof/require_tree'
|
4
|
+
|
5
|
+
module RequireProf
|
6
|
+
class Profile
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@running = false
|
10
|
+
@paused = false
|
11
|
+
@root = RequireTree.new('.')
|
12
|
+
@stack = [@root]
|
13
|
+
end
|
14
|
+
|
15
|
+
def running?
|
16
|
+
@running
|
17
|
+
end
|
18
|
+
|
19
|
+
def paused?
|
20
|
+
@paused
|
21
|
+
end
|
22
|
+
|
23
|
+
def start
|
24
|
+
install_hook
|
25
|
+
@running = true
|
26
|
+
end
|
27
|
+
|
28
|
+
def pause
|
29
|
+
@paused = true
|
30
|
+
end
|
31
|
+
|
32
|
+
def resume
|
33
|
+
@paused = false
|
34
|
+
end
|
35
|
+
|
36
|
+
def stop
|
37
|
+
remove_hook
|
38
|
+
@running = false
|
39
|
+
post_process
|
40
|
+
@root
|
41
|
+
end
|
42
|
+
|
43
|
+
def require(name)
|
44
|
+
node = RequireTree.new(name)
|
45
|
+
@stack.last << node
|
46
|
+
@stack << node
|
47
|
+
begin
|
48
|
+
time_before = Time.now.to_f
|
49
|
+
if MemorySampler.available?
|
50
|
+
memory_before = MemorySampler.memory_usage
|
51
|
+
overhead_time_before = Time.now.to_f - time_before
|
52
|
+
end
|
53
|
+
rp_original_require name
|
54
|
+
ensure
|
55
|
+
@stack.pop
|
56
|
+
if MemorySampler.available?
|
57
|
+
tmp_time = Time.now.to_f
|
58
|
+
memory_after = MemorySampler.memory_usage
|
59
|
+
overhead_time_after = Time.now.to_f - tmp_time
|
60
|
+
end
|
61
|
+
time_after = Time.now.to_f
|
62
|
+
end
|
63
|
+
node.total_time = (time_after - time_before) * 1000
|
64
|
+
if MemorySampler.available?
|
65
|
+
node.total_memory = memory_after - memory_before
|
66
|
+
node.overhead_time = (overhead_time_before + overhead_time_after) * 1000
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def install_hook
|
73
|
+
::Kernel.send(:define_method, :require) { |file| RequireProf.require file }
|
74
|
+
end
|
75
|
+
|
76
|
+
def remove_hook
|
77
|
+
::Kernel.send :alias_method, :require, :rp_original_require
|
78
|
+
end
|
79
|
+
|
80
|
+
def post_process
|
81
|
+
@root.process_time
|
82
|
+
@root.process_memory
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module RequireProf
|
2
|
+
class RequireTree
|
3
|
+
|
4
|
+
attr_reader :name
|
5
|
+
attr_accessor :time, :total_time, :memory, :total_memory, :overhead_time
|
6
|
+
|
7
|
+
def initialize(name)
|
8
|
+
@name = name
|
9
|
+
@children = {}
|
10
|
+
@time = 0.0
|
11
|
+
@total_time = 0.0
|
12
|
+
@overhead_time = 0.0
|
13
|
+
@memory = 0.0
|
14
|
+
@total_memory = 0.0
|
15
|
+
end
|
16
|
+
|
17
|
+
def <<(tree)
|
18
|
+
@children[tree.name] ||= tree
|
19
|
+
end
|
20
|
+
|
21
|
+
def [](name)
|
22
|
+
@children[name]
|
23
|
+
end
|
24
|
+
|
25
|
+
def children
|
26
|
+
@children.values
|
27
|
+
end
|
28
|
+
|
29
|
+
def process_time
|
30
|
+
children.map(&:process_time)
|
31
|
+
@overhead_time += children.map(&:overhead_time ).reduce(:+).to_f
|
32
|
+
@total_time -= overhead_time
|
33
|
+
@time = total_time - children.map(&:total_time).reduce(:+).to_f
|
34
|
+
end
|
35
|
+
|
36
|
+
def process_memory
|
37
|
+
children.map(&:process_memory)
|
38
|
+
@memory = total_memory - children.map(&:total_memory).reduce(:+).to_f
|
39
|
+
end
|
40
|
+
|
41
|
+
def to_h
|
42
|
+
{
|
43
|
+
name: name,
|
44
|
+
children: children.map(&:to_h),
|
45
|
+
time: time,
|
46
|
+
total_time: total_time,
|
47
|
+
memory: memory,
|
48
|
+
total_memory: total_memory
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'require_prof/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "require_prof"
|
8
|
+
spec.version = RequireProf::VERSION
|
9
|
+
spec.authors = ["Kirill Nikitin"]
|
10
|
+
spec.email = ["locke23rus@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Simple require profiler}
|
13
|
+
spec.description = %q{}
|
14
|
+
spec.homepage = "https://github.com/Locke23rus/require_prof"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "text-table", "~> 1.2"
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "minitest", "~> 5.5"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: require_prof
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kirill Nikitin
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: text-table
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.9'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.5'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.5'
|
69
|
+
description: ''
|
70
|
+
email:
|
71
|
+
- locke23rus@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/console
|
83
|
+
- bin/setup
|
84
|
+
- lib/require_prof.rb
|
85
|
+
- lib/require_prof/ext/kernel.rb
|
86
|
+
- lib/require_prof/memory_sampler.rb
|
87
|
+
- lib/require_prof/printers/abstract_printer.rb
|
88
|
+
- lib/require_prof/printers/table_printer.rb
|
89
|
+
- lib/require_prof/printers/tree_printer.rb
|
90
|
+
- lib/require_prof/profile.rb
|
91
|
+
- lib/require_prof/require_tree.rb
|
92
|
+
- lib/require_prof/version.rb
|
93
|
+
- require_prof.gemspec
|
94
|
+
homepage: https://github.com/Locke23rus/require_prof
|
95
|
+
licenses:
|
96
|
+
- MIT
|
97
|
+
metadata: {}
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 2.4.5
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: Simple require profiler
|
118
|
+
test_files: []
|