Files
wehub-resource-sync 28558dca80
Build / Build and test on ubuntu-24.04-arm for aarch64 (push) Waiting to run
Build / Build and test on windows-11-arm for aarch64 (push) Waiting to run
Build / Build and test on macos-latest for x86_64 (push) Waiting to run
Build / Build and test on windows-latest for x86_64 (push) Waiting to run
Build / Build and test on ubuntu-latest for x86_64 (push) Failing after 1s
Build / Build and test on ubuntu-latest (numpy 1.26) for x86_64 (push) Failing after 0s
chore: import upstream snapshot with attribution
2026-07-13 12:31:22 +08:00

38 lines
898 B
Python

# Small benchmark to get the even point where the threading code
# performs better than the serial code. See issue #36 for details.
from __future__ import print_function
from time import time
import numpy as np
from numpy.testing import assert_array_equal
import numexpr as ne
def bench(N):
print("*** array length:", N)
a = np.arange(N)
t0 = time()
ntimes = (1000*2**15) // N
for i in range(ntimes):
ne.evaluate('a>1000')
print("numexpr--> %.3g" % ((time()-t0)/ntimes,))
t0 = time()
for i in range(ntimes):
eval('a>1000')
print("numpy--> %.3g" % ((time()-t0)/ntimes,))
if __name__ == "__main__":
print("****** Testing with 1 thread...")
ne.set_num_threads(1)
for N in range(10, 20):
bench(2**N)
print("****** Testing with 2 threads...")
ne.set_num_threads(2)
for N in range(10, 20):
bench(2**N)