1+ {
2+ "metadata" : {
3+ "name" : " pstats_demo"
4+ },
5+ "nbformat" : 3 ,
6+ "nbformat_minor" : 0 ,
7+ "worksheets" : [
8+ {
9+ "cells" : [
10+ {
11+ "cell_type" : " markdown" ,
12+ "metadata" : {},
13+ "source" : [
14+ " # Pstats example:\n " ,
15+ " \n " ,
16+ " first build the profile data with:\n " ,
17+ " \n " ,
18+ " $ python -m cProfile -o profile_dump profile_example.py\n "
19+ ]
20+ },
21+ {
22+ "cell_type" : " code" ,
23+ "collapsed" : false ,
24+ "input" : [
25+ " import pstats\n "
26+ ],
27+ "language" : " python" ,
28+ "metadata" : {},
29+ "outputs" : [],
30+ "prompt_number" : 1
31+ },
32+ {
33+ "cell_type" : " code" ,
34+ "collapsed" : false ,
35+ "input" : [
36+ " p = pstats.Stats(\" profile_dump\" )\n "
37+ ],
38+ "language" : " python" ,
39+ "metadata" : {},
40+ "outputs" : [],
41+ "prompt_number" : 2
42+ },
43+ {
44+ "cell_type" : " code" ,
45+ "collapsed" : false ,
46+ "input" : [
47+ " p.print_stats()"
48+ ],
49+ "language" : " python" ,
50+ "metadata" : {},
51+ "outputs" : [
52+ {
53+ "output_type" : " stream" ,
54+ "stream" : " stdout" ,
55+ "text" : [
56+ " Tue May 14 17:42:50 2013 profile_dump\n " ,
57+ " \n " ,
58+ " 51403 function calls in 0.028 seconds\n " ,
59+ " \n " ,
60+ " Random listing order was used\n " ,
61+ " \n " ,
62+ " ncalls tottime percall cumtime percall filename:lineno(function)\n " ,
63+ " 51200 0.005 0.000 0.005 0.000 {method 'append' of 'list' objects}\n " ,
64+ " 1 0.000 0.000 0.028 0.028 profile_example.py:9(<module>)\n " ,
65+ " 1 0.001 0.001 0.028 0.028 profile_example.py:28(main)\n " ,
66+ " 100 0.020 0.000 0.024 0.000 profile_example.py:11(odd_numbers)\n " ,
67+ " 100 0.003 0.000 0.028 0.000 profile_example.py:19(sum_odd_numbers)\n " ,
68+ " 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}\n " ,
69+ " \n " ,
70+ " \n "
71+ ]
72+ },
73+ {
74+ "output_type" : " pyout" ,
75+ "prompt_number" : 4 ,
76+ "text" : [
77+ " <pstats.Stats instance at 0x1c50300>"
78+ ]
79+ }
80+ ],
81+ "prompt_number" : 4
82+ },
83+ {
84+ "cell_type" : " code" ,
85+ "collapsed" : false ,
86+ "input" : [
87+ " p.sort_stats('time').print_stats()"
88+ ],
89+ "language" : " python" ,
90+ "metadata" : {},
91+ "outputs" : [
92+ {
93+ "output_type" : " stream" ,
94+ "stream" : " stdout" ,
95+ "text" : [
96+ " Tue May 14 17:42:50 2013 profile_dump\n " ,
97+ " \n " ,
98+ " 51403 function calls in 0.028 seconds\n " ,
99+ " \n " ,
100+ " Ordered by: internal time\n " ,
101+ " \n " ,
102+ " ncalls tottime percall cumtime percall filename:lineno(function)\n " ,
103+ " 100 0.020 0.000 0.024 0.000 profile_example.py:11(odd_numbers)\n " ,
104+ " 51200 0.005 0.000 0.005 0.000 {method 'append' of 'list' objects}\n " ,
105+ " 100 0.003 0.000 0.028 0.000 profile_example.py:19(sum_odd_numbers)\n " ,
106+ " 1 0.001 0.001 0.028 0.028 profile_example.py:28(main)\n " ,
107+ " 1 0.000 0.000 0.028 0.028 profile_example.py:9(<module>)\n " ,
108+ " 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}\n " ,
109+ " \n " ,
110+ " \n "
111+ ]
112+ },
113+ {
114+ "output_type" : " pyout" ,
115+ "prompt_number" : 6 ,
116+ "text" : [
117+ " <pstats.Stats instance at 0x1c50300>"
118+ ]
119+ }
120+ ],
121+ "prompt_number" : 6
122+ },
123+ {
124+ "cell_type" : " code" ,
125+ "collapsed" : false ,
126+ "input" : [],
127+ "language" : " python" ,
128+ "metadata" : {},
129+ "outputs" : []
130+ }
131+ ],
132+ "metadata" : {}
133+ }
134+ ]
135+ }
0 commit comments