help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cputime() returns incorrect values


From: Anton Dereventsov
Subject: Re: cputime() returns incorrect values
Date: Sun, 2 Sep 2018 12:43:58 -0400

Sure, sorry about that. Here is the full message:

The following simple script generates and multiplies two random 1000-by-1000 matrices for 20 iterations and measures how long (in terms of both the wall-clock time and the cpu time) each iteration was executing.

Here is the code:
for i = 1 : 20
t0 = tic;
t1 = cputime;
rand(1000) * rand(1000);
printf('wall time: %.6f  |  cpu time: % .6f\n', toc(t0), cputime-t1);
endfor

And here is the output that I get:
wall time: 0.071920  |  cpu time:  0.031200
wall time: 0.071924  |  cpu time:  0.124800
wall time: 0.062927  |  cpu time:  0.062402
wall time: 0.056930  |  cpu time:  0.062400
wall time: 0.055934  |  cpu time:  1.000000
wall time: 0.056937  |  cpu time:  0.000000
wall time: 0.059940  |  cpu time:  0.093600
wall time: 0.055943  |  cpu time:  0.000000
wall time: 0.057947  |  cpu time:  1.000000
wall time: 0.068950  |  cpu time:  0.062400
wall time: 0.072955  |  cpu time: -0.781598
wall time: 0.062958  |  cpu time:  0.062400
wall time: 0.056961  |  cpu time:  0.000000
wall time: 0.055964  |  cpu time:  1.000000
wall time: 0.055968  |  cpu time:  0.000000
wall time: 0.060971  |  cpu time:  0.062400
wall time: 0.055974  |  cpu time:  1.000000
wall time: 0.068978  |  cpu time:  0.062402
wall time: 0.076982  |  cpu time:  0.156000
wall time: 0.074987  |  cpu time:  0.312002

The wall-clock time measured by tic-toc is believable but the cpu time is clearly false: sometimes it is negative and sometimes it is exactly 0 or 1.
These particular results were obtained in Octave 4.2.2 on Windows 7 machine with Intel i7-3610QM cpu but I observed the similar output on Ubuntu 16.04 with Intel Xeon E3-1535M v6.
Coincidentally, in Matlab the same code on the same machines returns reasonable cpu time.
Is this a bug or am I doing something terribly wrong?

Thanks,
Anton


Anton

On Sun, Sep 2, 2018 at 12:38 PM, Nicholas Jankowski <address@hidden> wrote:
On Sun, Sep 2, 2018, 11:33 Anton Dereventsov <address@hidden> wrote:
.

Here is the code:


And here is the output that I get:



Your code and output didn't come through in the mailing list emails. Can you resend in plain text?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]