lineprof 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 393ef2c1ceac2439ff2a0245dae2ea9ba8cfb2df
4
+ data.tar.gz: 8dccc11342de9485c529979b59c95f9b49dc494e
5
+ SHA512:
6
+ metadata.gz: 002457f42df37b5c6b91f15723f52a1694aa615bbed736281f9c4d568c1af6fd7363913ab1d42245a400931a38cdc1a21d740d2d533e48c9159a552822a349c0
7
+ data.tar.gz: 020d8df7ec44d10a0aab63ae986108cf5c4fe495d6f0e578ec0facff3320936cfa8745dbb77db8171aa978e1626f58e251e55835accfcd9f18e97ebf232be4bb
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in lineprof.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Takashi Kokubun
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # Lineprof
2
+
3
+ Easy-to-use line profiler for Ruby.
4
+
5
+ ## What's this?
6
+
7
+ [tmm1/rblineprof](https://github.com/tmm1/rblineprof) is a powerful line profiler for Ruby.
8
+ But rblineprof does not include a result formatter and its API is difficult to use.
9
+ This lineprof gem has a colored formatter, which is the same as [rack-lineprof](https://github.com/kainosnoema/rack-lineprof),
10
+ and simple API.
11
+
12
+ ## Usage
13
+
14
+ ```rb
15
+ require 'lineprof'
16
+
17
+ Lineprof.profile do
18
+ sleep 0.001
19
+ 100.times do
20
+ sleep 0.001
21
+ 1*2*3
22
+ 4*5*6
23
+ 7*8*9*10*11*12*13*14*15
24
+ 2**32
25
+ 2**128
26
+ end
27
+ end
28
+ ```
29
+
30
+ ![](http://i.gyazo.com/2fe139b45cd73dc9a3295d4b37b0063b.png)
31
+
32
+ ## License
33
+
34
+ MIT License
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/example.rb ADDED
@@ -0,0 +1,13 @@
1
+ require_relative './lib/lineprof'
2
+
3
+ Lineprof.profile do
4
+ sleep 0.001
5
+ 100.times do
6
+ sleep 0.001
7
+ 1*2*3
8
+ 4*5*6
9
+ 7*8*9*10*11*12*13*14*15
10
+ 2**32
11
+ 2**128
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ class Lineprof
2
+ VERSION = "0.0.1"
3
+ end
data/lib/lineprof.rb ADDED
@@ -0,0 +1,27 @@
1
+ require 'rblineprof'
2
+ require 'rack/lineprof'
3
+
4
+ class Lineprof
5
+ IGNORE_PATTERN = /lib\/lineprof\.rb$/
6
+
7
+ class << self
8
+ def profile(&block)
9
+ value = nil
10
+ result = lineprof(/./) { value = block.call }
11
+
12
+ puts Term::ANSIColor.blue("\n[Lineprof] #{'=' * 70}")
13
+ puts "\n#{format(result)}\n"
14
+ value
15
+ end
16
+
17
+ private
18
+
19
+ def format(result)
20
+ sources = result.map do |filename, samples|
21
+ next if filename =~ IGNORE_PATTERN
22
+ Rack::Lineprof::Source.new(filename, samples)
23
+ end
24
+ sources.compact.map(&:format).join("\n")
25
+ end
26
+ end
27
+ end
data/lineprof.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'lineprof/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "lineprof"
8
+ spec.version = Lineprof::VERSION
9
+ spec.authors = ["Takashi Kokubun"]
10
+ spec.email = ["takashikkbn@gmail.com"]
11
+ spec.summary = %q{Easy-to-use line profiler for Ruby.}
12
+ spec.description = %q{Easy-to-use line profiler for Ruby.}
13
+ spec.homepage = "https://github.com/k0kubun/lineprof"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "rblineprof", "~> 0.3.6"
22
+ spec.add_dependency "rack-lineprof", "~> 0.0.3"
23
+
24
+ spec.add_development_dependency "bundler"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "pry"
27
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lineprof
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Takashi Kokubun
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rblineprof
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.3.6
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.3.6
27
+ - !ruby/object:Gem::Dependency
28
+ name: rack-lineprof
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Easy-to-use line profiler for Ruby.
84
+ email:
85
+ - takashikkbn@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - example.rb
96
+ - lib/lineprof.rb
97
+ - lib/lineprof/version.rb
98
+ - lineprof.gemspec
99
+ homepage: https://github.com/k0kubun/lineprof
100
+ licenses:
101
+ - MIT
102
+ metadata: {}
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubyforge_project:
119
+ rubygems_version: 2.4.5
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: Easy-to-use line profiler for Ruby.
123
+ test_files: []
124
+ has_rdoc: