Menu
Coddy logo textTech

Practice #5

Coddy의 Python 데코레이터 코스 레슨. 12개 중 12번째.

challenge icon

챌린지

쉬움

memory_usage라는 데코레이터를 작성하여 함수의 메모리 사용량을 측정하세요.

데코레이터는 함수가 실행되기 전과 후에 함수가 사용한 메모리 양을 나타내는 메시지를 다음 형식으로 출력해야 합니다.

Memory usage: 0 Bytes

현재 "메모리 사용량"(정확히는 아님)을 가져오려면 다음을 사용하세요.

import tracemalloc
tracemalloc.start()
res = # some operations
current, peak = tracemalloc.get_traced_memory()

current에는 Bytes 단위의 값이 저장됩니다.

마지막에는 함수의 결과를 반환하세요!

REQUIRED OUTPUT FORMAT: <translation> [Your translated content here] </translation>

직접 해보기

Python 데코레이터의 모든 레슨

직접 연습해 보세요: 온라인 Python 컴파일러