Skip to content

Instantly share code, notes, and snippets.

@kolibril13
Created December 2, 2025 07:08
Show Gist options
  • Select an option

  • Save kolibril13/3aed7fef7d1ebfc4fbc94d4947c65f58 to your computer and use it in GitHub Desktop.

Select an option

Save kolibril13/3aed7fef7d1ebfc4fbc94d4947c65f58 to your computer and use it in GitHub Desktop.
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "uvtrick",
# ]
# ///
from uvtrick import Env
def benchmark():
import time
import sys
version = sys.version_info
print(f"Running benchmark with Python {version.major}.{version.minor}")
total = 0
N = 200_000_000
start = time.time()
for i in range(N):
total = total+i
duration = time.time() - start
print(f"Adding {N} elements took {duration:.2f} seconds.\n")
print("Starting benchmark tests:")
Env(python="3.11").run(benchmark)
Env(python="3.12").run(benchmark)
Env(python="3.13").run(benchmark)
Env(python="3.14").run(benchmark)
@kolibril13
Copy link
Author

# /// script
# requires-python = ">=3.12"
# dependencies = [
#     "uvtrick",
# ]
# ///

from uvtrick import Env

def benchmark():
    import time
    import numpy as np
    import sys
    version = sys.version_info
    print(f"Running benchmark with numpy=={np.__version__} and Python {version.major}.{version.minor}")

    N = 9000
    A = np.random.rand(N, N)
    B = np.random.rand(N, N)
    start = time.time()
    C = np.dot(A, B)
    duration = time.time() - start
    print(f"Multiplying two {N}x{N} matrices took {duration:.2f} s.\n")


print("Starting benchmark tests:")
Env("numpy==2.2.2", python="3.11").run(benchmark)
Env("numpy==2.2.2", python="3.12").run(benchmark)
Env("numpy==2.2.2", python="3.13").run(benchmark)
Env("numpy==2.2.2", python="3.14").run(benchmark)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment