Numpy slow at vector cross product?
eryk sun
eryksun at gmail.com
Mon Nov 21 09:02:13 EST 2016
On Mon, Nov 21, 2016 at 1:38 AM, BartC <bc at freeuk.com> wrote:
> On 20/11/2016 20:46, DFS wrote:
>>
>> import sys, time, numpy as np
>> loops=int(sys.argv[1])
>>
>> x=np.array([1,2,3])
>> y=np.array([4,5,6])
>> start=time.clock()
In Unix, time.clock doesn't measure wall-clock time, but rather an
approximation to the CPU time used by the current process. On the
other hand, time.time calls gettimeofday, if available, which has a
resolution of 1 microsecond. Python 2 timing tests should use
time.time on Unix.
In Windows, time.time calls GetSystemTimeAsFileTime, which has a
default resolution of only about 15 ms, adjustable down to about 1 ms.
On other hand, time.clock calls QueryPerformanceCounter, which has a
resolution of about 100 nanoseconds. Python 2 timing tests should use
time.clock on Windows.
In Python 3.3+, timing tests should use time.perf_counter. In Linux
this calls clock_gettime using a monotonic clock with a resolution of
1 nanosecond, and in Windows it calls QueryPerformanceCounter.
In any case, timeit.default_timer selects the best function to call
for a given platform.
More information about the Python-list
mailing list