timer - Running time for python -
hi trying estimate run time fft code form numpy. different input length n. following code.
import cmath import math random import uniform numpy.fft import fft import time in range(3,10): n = 2**i x = [uniform(-32768,32767) in range(n)] t0 = time.clock() x = fft(x) t1 = time.clock() print t1-t0
this result got, first line input length n=3 should fastest one, no matter how many times run, first 1 largest one. guess problem timer, don't know exact reason it. can explain me?
output:
4.8e-05 3e-05 1.7e-05 6e-05 3.1e-05 5.4e-05 9.6e-05
the time interval small accurately measured time.clock(), there latency jitter in os call. instead, enough work (loop each fft few thousand or million times) until work measured takes few seconds. repeat each measurement several times , take average, there may other system overheads (cache flushes, process switches, etc.) can vary performance.
Comments
Post a Comment