File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ # pdb 실행 해보기
2
+
3
+ <img width =" 807 " alt =" Screenshot 2024-06-30 at 5 23 18 PM " src =" https://github.com/why-arong/CPython-Guide/assets/68311908/63f4b02c-01e6-493e-a4ea-cd66be6a8a21 " >
4
+
5
+
6
+
7
+ # CProfile 예제 직접 실행해보기
8
+
9
+ ``` python3
10
+ # example.py
11
+
12
+ import cProfile
13
+ import pstats
14
+ import io
15
+
16
+ def slow_function ():
17
+ total = 0
18
+ for i in range (10000 ):
19
+ for j in range (10000 ):
20
+ total += i * j
21
+ return total
22
+
23
+ def fast_function ():
24
+ return sum (i * j for i in range (1000 ) for j in range (1000 ))
25
+
26
+ def main ():
27
+ slow_function()
28
+ fast_function()
29
+
30
+ if __name__ == ' __main__' :
31
+ pr = cProfile.Profile()
32
+ pr.enable()
33
+ main()
34
+ pr.disable()
35
+
36
+ s = io.StringIO()
37
+ sortby = ' cumulative'
38
+ ps = pstats.Stats(pr, stream = s).sort_stats(sortby)
39
+ ps.print_stats()
40
+ print (s.getvalue())
41
+
42
+ ```
43
+ <img width =" 802 " alt =" Screenshot 2024-06-30 at 5 31 22 PM " src =" https://github.com/why-arong/CPython-Guide/assets/68311908/4fafd154-2e3c-4551-899c-5b19cdb67651 " >
You can’t perform that action at this time.
0 commit comments