Exercise_time_video_51

mail@pastecode.io avatar
unknown
plain_text
2 years ago
614 B
0
Indexable
Never
##Exercise - checking if value is in a range 
import time

def function_performance(func, arg, how_many_times = 1): 
    sum = 0 

    for i in range(0, how_many_times): 
        start = time.perf_counter() 
        func(arg)
        end = time.perf_counter()
        sum = sum + (end-start)

    return sum 

setContainer = (i for i in range(1000))
listContainer = (i for i in range(1000))

def is_value_in(what_value): 
    if what_value in listContainer: 
        return True 
    else: 
        return False 

print(function_performance(is_value_in, 1500, 50000)) 
##result = is_value_in(549) 
##print(result)