3 ms·
Ran the following numpy program, which resulted in a time of 0.01116s, faster than the article's benchmark but slightly slower than my Dyalog timing of 0.0093s.
by mlochbaum 5y ago
Ran the following numpy program, which resulted in a time of 0.01116s, faster than the article's benchmark but slightly slower than my Dyalog timing of 0.0093s. Assuming relative times are consistent across CPUs, this would put Dyalog on 8-byte floats just ahead of Q on 8-byte ints. Floating-point vector instructions take longer than integer ones; while overflow checking could turn things the other way, K and Q famously don't do it. It's not consistent with a sum of 100 runs as geocar suggests.
import numpy as np
import time
N = 1000 * 1000
pA = np.random.randint(0, 5, N)
pB = np.random.randint(0, 5, N)
sA = np.random.randint(0, 100, N)
sB = np.random.randint(0, 100, N)
start = time.perf_counter()
runs = 100
for i in range(runs):
bS = sA * (pA >= pB) + sB * (pA <= pB)
end = time.perf_counter()
print((end - start)/runs)