miniprof 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a58f4c04b94083b464628ef5086602a6243e44b2
4
+ data.tar.gz: 0376251c8eb208b8cfee5538e7dcdbd200f09dbb
5
+ SHA512:
6
+ metadata.gz: 39fc1340fcd198452f8f7d60c75275f355d038cd77909577ecd68c3707a4ac412e2d331b8b341dd762bff148c810eb68b715f5d02cec74233f0b82d77719aa59
7
+ data.tar.gz: 34359ca90878712c81702cf456943c523d8365205890d36076411531be72460a5ec81976310372406fd8d1c09cabdf8264c0d0a5ff97dc6b4eec42196c848b8f
@@ -0,0 +1,12 @@
1
+ -----BEGIN PGP SIGNATURE-----
2
+ Version: GnuPG/MacGPG2 v2.0.19 (Darwin)
3
+ Comment: GPGTools - http://gpgtools.org
4
+
5
+ iQEcBAABCgAGBQJS2F0HAAoJEP5F5V2hilTWnPoIAK2AOUsnInA5QeYp81zUkWk7
6
+ H1O5Jo+zNBfi0NvWRt8/AtUAFjOD4v1aN3zYsX2E/PM1DQytgGovvGbPNSVdObr4
7
+ tYuwdpiLrk9eCfTkgzOg8WZSr96sXOSyhmFlhwNrDF4/67jR+1yNGDsd6s8LWTxK
8
+ HaH+aQMt85DnrUiZEkiH5qaSc6NOUoi3AqNn2kcnHqEAf1E7A255L0NjKkd0YQIE
9
+ KZIqRPpU2R5O7myCLxnol4wJhrgLsdxRowX3wfMLcQgIbJSjNIV0p/8lKUMImlED
10
+ zt7QAJlPdsGI9nFs4V2n1ztt8Mar7fOKuJUQBm/mPunjzsujMwcxu+jkcIZJZn8=
11
+ =PVzU
12
+ -----END PGP SIGNATURE-----
@@ -0,0 +1,12 @@
1
+ -----BEGIN PGP SIGNATURE-----
2
+ Version: GnuPG/MacGPG2 v2.0.19 (Darwin)
3
+ Comment: GPGTools - http://gpgtools.org
4
+
5
+ iQEcBAABCgAGBQJS2F0HAAoJEP5F5V2hilTW3TQH/RPwrf4tYAGxtF8jDX6B1ZcC
6
+ HWUMNPZXtK2aOOqSDSWAMkKCVZ6dXhhushfzCCtXplX/UkLioOHebxHGeDWOUyp0
7
+ 0bo7AWNeWFeE4iN00AObF93z5SjWvbQ7IKo3R69evzjg1J1zevYEW9VzhRtw5En/
8
+ oS0pai9ihffluMMlv5ibKISbn+4ZXAjd+T3/OcVop757hz5ffF/jdc2InywZrcOR
9
+ EwABCKqXenlCCiZB+WsScfxGxMWpZao9IBxX8tDDJPWzioy9nbCI5/nRvJwtILuQ
10
+ 1BEJdZXpOYTIYXOY86ia3heak+oMa/f7WdAnVwQa69QbyWFnuF8qRhprBWgkl3s=
11
+ =55h8
12
+ -----END PGP SIGNATURE-----
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in miniprof.gemspec
4
+ gemspec
@@ -0,0 +1,31 @@
1
+ Copyright (c) 2012-2014 Grant T. Olson
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are
6
+ met:
7
+
8
+ * Redistributions of source code must retain the above copyright
9
+ notice, this list of conditions and the following disclaimer.
10
+
11
+ * Redistributions in binary form must reproduce the above
12
+ copyright notice, this list of conditions and the following
13
+ disclaimer in the documentation and/or other materials provided
14
+ with the distribution.
15
+
16
+ * Neither the name of the Grant T. Olson nor the names of
17
+ additional contributors may be used to endorse or promote
18
+ products derived from this software without specific prior
19
+ written permission.
20
+
21
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,64 @@
1
+ MiniProf
2
+ ========
3
+
4
+ A quick-and-dirty lightweight profiler that allows you to measure
5
+ the various steps in walltime. The main benefit of this is that it
6
+ is much easier to control and interpret the output than raw
7
+ profiling data which can overwhelm you.
8
+
9
+ Calling MiniProf.profile returns a block containing a MiniProf
10
+ instance. This instance will record the time for each step when you
11
+ feed in a step description via the << operator.
12
+
13
+ This tool is indented for development only. We probably don't ever
14
+ want to commit active MiniProf code and/or release it to production.
15
+
16
+ Sample usage
17
+ ------------
18
+
19
+ johnmudhead:pikimal grant$ cat mini_prof_test.rb
20
+ def test_method
21
+ MiniProf.profile do |tick|
22
+ #simulated possibly long operation
23
+ sleep 1
24
+ tick << "Step one complete"
25
+
26
+ # simulated really long operation
27
+ sleep 5
28
+ tick << "Step two complete"
29
+ end
30
+ end
31
+
32
+ test_method
33
+ johnmudhead:pikimal grant$ rails console < mini_prof_test.rb
34
+ Loading development environment (Rails 3.0.7)
35
+
36
+ ...
37
+
38
+ Tick: (0 ms since last, 0 ms since start) Started mini_prof...
39
+ Tick: (1000 ms since last, 1000 ms since start) Step one complete
40
+ Tick: (5000 ms since last, 6000 ms since start) Step two complete
41
+ Tick: (0 ms since last, 6000 ms since start) Ended mini_prof...
42
+ => nil
43
+ ruby-1.9.2-p0 >
44
+
45
+ ### Verifying the software
46
+
47
+ The gem is signed with
48
+ [rubygems-openpgp](https://github.com/grant-olson/rubygems-openpgp).
49
+ Assuming you have rubygems-openpgp configured, you can verify the
50
+ software:
51
+
52
+ gem install bmf --verify
53
+
54
+ More details are available at the [rubygems-openpgp project
55
+ page](https://github.com/grant-olson/rubygems-openpgp).
56
+
57
+ Signing Key:
58
+
59
+ pub 2048R/E3B5806F 2010-01-11 [expires: 2014-01-03]
60
+ Key fingerprint = A530 C31C D762 0D26 E2BA C384 B6F6 FFD0 E3B5 806F
61
+ uid Grant T. Olson (Personal email) <kgo at grant-olson dot net>
62
+ sub 2048R/6A8F7CF6 2010-01-11 [expires: 2014-01-03]
63
+ sub 2048R/A18A54D6 2010-03-01 [expires: 2014-01-03]
64
+ sub 2048R/D53982CE 2010-08-31 [expires: 2014-01-03]
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,56 @@
1
+ require "miniprof/version"
2
+
3
+ class MiniProf
4
+ # Get the seconds since epoch. using to_f provides sub-second
5
+ # accuracy
6
+ def seconds_since_epoch
7
+ Time.now.to_f
8
+ end
9
+
10
+ # Initialize the profiler
11
+ #
12
+ # The optional marker will prefix each message, so you can
13
+ # distingish the output of multiple profilers.
14
+ def initialize marker="", opts={}
15
+ @start_time = seconds_since_epoch
16
+ @last_tick_time = @start_time
17
+ @marker = marker
18
+ @enabled = true
19
+ @enabled = opts[:enabled] if opts.has_key?(:enabled)
20
+ end
21
+
22
+ # Main loop
23
+ def profile &block
24
+ self.<< "Started mini_prof..."
25
+ return_value = yield self
26
+ self.<< "Ended mini_prof..."
27
+ return return_value
28
+ end
29
+
30
+ def seconds_to_ms seconds
31
+ (seconds * 1000).to_i
32
+ end
33
+
34
+ # Print out a mesage indicating how long it's been since the last
35
+ # step and since the start of profiling
36
+ def << msg
37
+ return if @enabled == false
38
+
39
+ new_time = seconds_since_epoch
40
+ since_start = seconds_to_ms(new_time - @start_time)
41
+ since_last = seconds_to_ms(new_time - @last_tick_time)
42
+ @last_tick_time = new_time
43
+
44
+ msg = "Tick: (#{since_last} ms since last, #{since_start} ms since start) #{msg}"
45
+ msg = @marker + " " + msg if !@marker.empty?
46
+ puts msg
47
+ end
48
+
49
+ # Create a profiler object and execute it. The optional marker will
50
+ # print at the beginning of each line of output.
51
+ def self.profile marker="",opts={}, &block
52
+ mp = MiniProf.new marker, opts
53
+ mp.profile &block
54
+ end
55
+
56
+ end
@@ -0,0 +1,3 @@
1
+ class MiniProf
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'miniprof/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "miniprof"
8
+ spec.version = MiniProf::VERSION
9
+ spec.authors = ["Grant T. Olson"]
10
+ spec.email = ["kgo@grant-olson.net"]
11
+ spec.summary = %q{Simple tool to assist with manual profiling}
12
+ spec.homepage = ""
13
+ spec.license = "BSD"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.5"
21
+ spec.add_development_dependency "rake"
22
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: miniprof
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Grant T. Olson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description:
42
+ email:
43
+ - kgo@grant-olson.net
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - lib/miniprof.rb
54
+ - lib/miniprof/version.rb
55
+ - miniprof.gemspec
56
+ homepage: ''
57
+ licenses:
58
+ - BSD
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.2.0
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Simple tool to assist with manual profiling
80
+ test_files: []
@@ -0,0 +1,12 @@
1
+ -----BEGIN PGP SIGNATURE-----
2
+ Version: GnuPG/MacGPG2 v2.0.19 (Darwin)
3
+ Comment: GPGTools - http://gpgtools.org
4
+
5
+ iQEcBAABCgAGBQJS2F0HAAoJEP5F5V2hilTW3SkIAIk9E7k5BS+55QdrZ9EPigvR
6
+ L7dPnOBgU1RhSggrjBAzbT6MxHAj/VrkdhQoSN841jQP/3owWcf6Y+qAqfjqjKeX
7
+ 1gr/3TMFfVfb/SHTEqmkdzhz0xBf/QsLfkRYwDBk4FW9JrwfYx8AHD3CBM/0AacA
8
+ gENpwkpXmdMSmZHUkR1GBre1REwc+rV5ZtS2NEMx49ri9kq0jV9sn4XJ1d8D7R9R
9
+ X32r22in+GiXbZsyhqE5t1oEjZ37Uxt2cTWQX6NtUCzwBnuksyCbY84FZ0SV/89/
10
+ HvLOnFOD7VnCpdEi14no/3B/fpeEbdlI4CwMDkOaHLF9NoDeGQ1tVS+oF4LpMwo=
11
+ =Cfp0
12
+ -----END PGP SIGNATURE-----