Created
December 27, 2020 00:09
-
-
Save dengemann/03a097ddda70dcaeecef95c69f87cc73 to your computer and use it in GitHub Desktop.
This file contains 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
# License: BSD (3-clause) | |
# Author: Denis A. Engemann <[email protected]> | |
# Based on : | |
# https://gist.github.com/markus-beuckelmann/8bc25531b11158431a5b09a45abd6276 | |
import platform | |
import psutil | |
import datetime | |
from time import time | |
import numpy as np | |
import pandas as pd | |
# Let's take the randomness out of random numbers (for reproducibility) | |
rng = np.random.RandomState(0) | |
p = 2048 | |
A = np.random.random((p, p)) | |
B = np.random.random((p, p)) | |
E = np.random.random((int(p / 2), int(p / 4))) | |
F = np.random.random((int(p / 2), int(p / 2))) | |
G = np.random.random((int(p / 2), int(p / 2))) | |
def bench(function, runs=50): | |
deltas = list() | |
for ii in range(runs): | |
tt = time() | |
function() | |
delta = time() - tt | |
deltas.append(delta) | |
return np.array(deltas) | |
results = dict( | |
dot=bench(lambda: A @ B), | |
svd=bench(lambda: np.linalg.svd(E, full_matrices = False)), | |
eigh=bench(lambda: np.linalg.eigh(G)) | |
) | |
results_df = pd.DataFrame(results) | |
results_df['ram'] = str( | |
round(psutil.virtual_memory().total / (1024.0 **3))) + " GB" | |
results_df['arch'] = platform.machine() | |
results_df['version'] = platform.platform() | |
date = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%f") | |
results_df.to_csv('numpy/bench-%s.csv' % date[:-7]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment