desihub / specter

A toolkit for simulating multi-object spectrographs
Other
8 stars 7 forks source link

Faster xnorm #69

Closed sbailey closed 5 years ago

sbailey commented 5 years ago

This PR provides another small speedup. TraceSet._xnorm(x) now requires scalar or array input, but not list or tuple input. There was only one place that was providing a list and it was easy to change that to an array, instead of having xnorm have to check every time it is called (which is many many times and adds up).

Note: I didn't want to use np.asarray(x) for the conversion because that also has to do checking and also changes the type when given a scalar input (true float -> 0-dim array of float).

lastephey commented 5 years ago

testing in progress

lastephey commented 5 years ago

Typical test case runs in about ~4:40 on haswell, this runs in about ~ 4:38. (Limited statistics, only ran one time.)

+1 for removing isinstance!

sbailey commented 5 years ago

Testing on my laptop with a single core and smaller test case has a ~3% improvement. Main point is to remove the easy silly small slowdowns so that we (i.e. @lastephey) can focus on the hard ones. :) Thanks for the double check.