Skip to content

Instantly share code, notes, and snippets.

@dtaivpp
Created December 11, 2019 15:55
Show Gist options
  • Save dtaivpp/2642a600459b6c36e130352b5c30eb36 to your computer and use it in GitHub Desktop.
Save dtaivpp/2642a600459b6c36e130352b5c30eb36 to your computer and use it in GitHub Desktop.
import random
from time import time
random.seed(time())
times = {'listComprehension': 0, 'append': 0, 'preAllocate': 0}
for i in range(0,100):
endRange = random.randint(100_000, 10_000_000)
startTime = time()
listComprehension = [i for i in range(0, endRange)]
endTime = time()
times.update({'listComprehension': endTime - startTime})
#Repeat for other methods with same endRange
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment