Skip to content

Commit

Permalink
[김필모] 13주차 미션 제출 (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
why-arong authored Jul 8, 2024
1 parent 86d42a9 commit dad2623
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions 8th_members/김필모/13주차.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# pdb 실행 해보기

<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">



# CProfile 예제 직접 실행해보기

```python3
# example.py

import cProfile
import pstats
import io

def slow_function():
total = 0
for i in range(10000):
for j in range(10000):
total += i * j
return total

def fast_function():
return sum(i * j for i in range(1000) for j in range(1000))

def main():
slow_function()
fast_function()

if __name__ == '__main__':
pr = cProfile.Profile()
pr.enable()
main()
pr.disable()

s = io.StringIO()
sortby = 'cumulative'
ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
ps.print_stats()
print(s.getvalue())

```
<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 comments on commit dad2623

Please sign in to comment.