Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import time
- ARR_SIZE = 1000000
- TEST_COUNT = 1000
- def main():
- arr = create_array(ARR_SIZE)
- t = time.process_time()
- for i in range(0, TEST_COUNT):
- imax = arrmax(arr)
- t = time.process_time() - t
- print(t / TEST_COUNT)
- print(str(imax) + '\n') # just not to left imax unused
- def arrmax(arr):
- max = arr[0]
- for i in arr[1:]:
- if i > max: max = i
- return max
- def create_array(n):
- arr = []
- for i in range(0, n):
- r = random.randint(0, 65535)
- arr.append(r)
- return arr
- if __name__ == "__main__":
- main()
Add Comment
Please, Sign In to add comment