Skip to content

Commit a605a8f

Browse files
authored
Create python-runtime.py
Adding the code for calculating the runtime of any python script
1 parent ca6bb4a commit a605a8f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import time
2+
3+
startTime_1 = time.time()
4+
import pandas as pd
5+
import numpy as np
6+
executionTime_1 = (time.time() - startTime_1)
7+
print('Time to import modules: ' + str(executionTime_1))
8+
9+
startTime_2 = time.time()
10+
df = pd.DataFrame(np.random.randint(1,9999,size=(10000000, 1)), columns=['Random numbers'])
11+
df['Random numbers'] = df['Random numbers'].astype(str)
12+
executionTime_2 = (time.time() - startTime_2)
13+
print('Time to run the main Python script: ' + str(executionTime_2))

0 commit comments

Comments
 (0)