Skip to content

Commit dad2623

Browse files
authored
[김필모] 13주차 미션 제출 (#123)
1 parent 86d42a9 commit dad2623

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

8th_members/김필모/13주차.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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">

0 commit comments

Comments
 (0)