단답 퀴즈: %lprun 사용 단계
아래는 convert_units() 함수로, 좋아하는 슈퍼히어로들의 키와 몸무게를 미터법에서 야드파운드법으로 변환해요.
def convert_units(heroes, heights, weights):
new_hts = [ht * 0.39370 for ht in heights]
new_wts = [wt * 2.20462 for wt in weights]
hero_data = {}
for i,hero in enumerate(heroes):
hero_data[hero] = (new_hts[i], new_wts[i])
return hero_data
슈퍼히어로들의 목록(heroes)과 각 히어로의 키(센티미터)와 몸무게(킬로그램)가 각각 NumPy 배열(hts, wts)로 로드되어 있다고 가정해 봅시다.
슈퍼히어로 데이터에 대해 convert_units() 함수를 프로파일링하면서 줄 단위 실행 시간을 보고 싶다면, 어떤 단계를 거쳐야 하나요?
이 연습은 강의의 일부입니다
