stackprof 0.2.2 → 0.2.3
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 +4 -4
- data/README.md +5 -4
- data/bin/stackprof +15 -4
- data/bin/stackprof-flamegraph +2 -0
- data/bin/stackprof-gprof2dot +2 -0
- data/ext/stackprof.c +77 -14
- data/lib/stackprof/middleware.rb +4 -3
- data/lib/stackprof/report.rb +26 -1
- data/stackprof.gemspec +3 -1
- data/test/test_stackprof.rb +26 -0
- data/vendor/FlameGraph/README +134 -0
- data/vendor/FlameGraph/flamegraph.pl +494 -0
- data/vendor/gprof2dot/gprof2dot.py +3266 -0
- data/vendor/gprof2dot/hotshotmain.py +70 -0
- metadata +10 -2
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
#
|
3
|
+
# Copyright 2007 Jose Fonseca
|
4
|
+
#
|
5
|
+
# This program is free software: you can redistribute it and/or modify it
|
6
|
+
# under the terms of the GNU Lesser General Public License as published
|
7
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
#
|
18
|
+
|
19
|
+
def run(statement, filename=None, sort=-1):
|
20
|
+
import os, tempfile, hotshot, hotshot.stats
|
21
|
+
logfd, logfn = tempfile.mkstemp()
|
22
|
+
prof = hotshot.Profile(logfn)
|
23
|
+
try:
|
24
|
+
prof = prof.run(statement)
|
25
|
+
except SystemExit:
|
26
|
+
pass
|
27
|
+
try:
|
28
|
+
try:
|
29
|
+
prof = prof.run(statement)
|
30
|
+
except SystemExit:
|
31
|
+
pass
|
32
|
+
prof.close()
|
33
|
+
finally:
|
34
|
+
stats = hotshot.stats.load(logfn)
|
35
|
+
stats.strip_dirs()
|
36
|
+
stats.sort_stats(sort)
|
37
|
+
if filename is not None:
|
38
|
+
result = stats.dump_stats(filename)
|
39
|
+
else:
|
40
|
+
result = stats.print_stats()
|
41
|
+
os.unlink(logfn)
|
42
|
+
return result
|
43
|
+
|
44
|
+
def main():
|
45
|
+
import os, sys
|
46
|
+
from optparse import OptionParser
|
47
|
+
usage = "hotshotmain.py [-o output_file_path] [-s sort] scriptfile [arg] ..."
|
48
|
+
parser = OptionParser(usage=usage)
|
49
|
+
parser.allow_interspersed_args = False
|
50
|
+
parser.add_option('-o', '--outfile', dest="outfile",
|
51
|
+
help="Save stats to <outfile>", default=None)
|
52
|
+
parser.add_option('-s', '--sort', dest="sort",
|
53
|
+
help="Sort order when printing to stdout, based on pstats.Stats class", default=-1)
|
54
|
+
|
55
|
+
if not sys.argv[1:]:
|
56
|
+
parser.print_usage()
|
57
|
+
sys.exit(2)
|
58
|
+
|
59
|
+
(options, args) = parser.parse_args()
|
60
|
+
sys.argv[:] = args
|
61
|
+
|
62
|
+
if (len(sys.argv) > 0):
|
63
|
+
sys.path.insert(0, os.path.dirname(sys.argv[0]))
|
64
|
+
run('execfile(%r)' % (sys.argv[0],), options.outfile, options.sort)
|
65
|
+
else:
|
66
|
+
parser.print_usage()
|
67
|
+
return parser
|
68
|
+
|
69
|
+
if __name__ == "__main__":
|
70
|
+
main()
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stackprof
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aman Gupta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -43,6 +43,8 @@ description: stackprof is a fast sampling profiler for ruby code, with cpu, wall
|
|
43
43
|
email: aman@tmm1.net
|
44
44
|
executables:
|
45
45
|
- stackprof
|
46
|
+
- stackprof-flamegraph
|
47
|
+
- stackprof-gprof2dot
|
46
48
|
extensions:
|
47
49
|
- ext/extconf.rb
|
48
50
|
extra_rdoc_files: []
|
@@ -53,6 +55,8 @@ files:
|
|
53
55
|
- README.md
|
54
56
|
- Rakefile
|
55
57
|
- bin/stackprof
|
58
|
+
- bin/stackprof-flamegraph
|
59
|
+
- bin/stackprof-gprof2dot
|
56
60
|
- ext/extconf.rb
|
57
61
|
- ext/stackprof.c
|
58
62
|
- lib/stackprof/middleware.rb
|
@@ -61,6 +65,10 @@ files:
|
|
61
65
|
- stackprof.gemspec
|
62
66
|
- test/test_middleware.rb
|
63
67
|
- test/test_stackprof.rb
|
68
|
+
- vendor/FlameGraph/README
|
69
|
+
- vendor/FlameGraph/flamegraph.pl
|
70
|
+
- vendor/gprof2dot/gprof2dot.py
|
71
|
+
- vendor/gprof2dot/hotshotmain.py
|
64
72
|
homepage: http://github.com/tmm1/stackprof
|
65
73
|
licenses:
|
66
74
|
- MIT
|