#python #anaconda #jupyter-notebook #visual-code #html #css #javascript #http

제목실습자료 step_15_search 부분 질문입니다.2019-06-08 20:15
작성자

import time

def time_it(searchMethod, lst, value):
    t1 = time.perf_counter()
    if(searchMethod(lst, value) == -1):
        print("Error in search.")
    t2 = time.perf_counter()
    return (t2-t1)

def linear_search_for(lst, value):
    i = 0
    for i in range(len(lst)):
        if lst[i] == value:
            return i
    return -1

이 구문에서 
time_it 함수 불러올때 같은 값을 넣고 여러번 실행해 봤는데
매번 실행할때마다 걸리는 시간이 다르게 나옵니다.
시간이 다르게 나오는 이유가 뭔가요?
(아래 그림의 소수점이 나오는 숫자가 걸리는 시간)

mb-file.php?path=2019%2F06%2F08%2FF298_%EC%9B%B9%ED%8C%8C%20%EB%AC%B8%EC%9D%98.PNG 
댓글