Last active
January 13, 2020 16:01
-
-
Save dtaivpp/b1c4fa471faf2981386b39786c5e63d1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from time import time | |
import numpy as np | |
import pandas as pd | |
# Initilize Random | |
random.seed(time()) | |
#### List Tests #### | |
# How many test passes to run | |
num_tests = 25 | |
# Create a dict for which to store tests | |
data = {'length':[], 'listComprehension': [], 'append': [], 'preAllocate': [], 'while': []} | |
for i in range(0, num_tests): | |
# Randomize list length | |
end = random.randint(100_000, 10_000_000) | |
startTime = time() | |
listComprehension = [i for i in range(0, end)] | |
endTime = time() | |
# Add timed entry | |
tmpdata['listComprehension'].append(endTime - startTime) | |
# Get the median for all the rows | |
df = pd.DataFrame(data) | |
print(df.describe()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment