Skip to content

Instantly share code, notes, and snippets.

@cosmic-cortex
Last active June 9, 2020 05:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cosmic-cortex/0842339be2698cddbbd19f35fa5143f1 to your computer and use it in GitHub Desktop.
Save cosmic-cortex/0842339be2698cddbbd19f35fa5143f1 to your computer and use it in GitHub Desktop.
from timeit import timeit
from numpy.random import random as random_np
from random import random as random_py
n_runs = 10000000
t_builtin = timeit(random_py, number=n_runs)
t_numpy = timeit(random_np, number=n_runs)
print(f"Built-in random:\t{t_builtin}s")
print(f"NumPy random: \t{t_numpy}s")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment