help-octave
[Top][All Lists]
Advanced

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

Re: cputime() returns incorrect values


From: Dmitri A. Sergatskov
Subject: Re: cputime() returns incorrect values
Date: Sun, 2 Sep 2018 12:04:58 -0500



On Sun, Sep 2, 2018 at 11:51 AM Anton Dereventsov <address@hidden> wrote:
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.

 
I can reproduce this on Fedora with 4.2.2. it works fine with the current stable (4.4.1) version.

wall time: 0.112784  |  cpu time:  0.109635
wall time: 0.102103  |  cpu time:  0.101593
wall time: 0.098640  |  cpu time:  0.098136
wall time: 0.101773  |  cpu time:  0.101256
wall time: 0.097494  |  cpu time:  0.096882
wall time: 0.096570  |  cpu time:  0.096078
wall time: 0.097592  |  cpu time:  0.097008
wall time: 0.096049  |  cpu time:  0.095532
wall time: 0.096685  |  cpu time:  0.096213
wall time: 0.096337  |  cpu time:  0.095828
wall time: 0.097368  |  cpu time:  0.096865
wall time: 0.096752  |  cpu time:  0.096263
wall time: 0.096347  |  cpu time:  0.095957
wall time: 0.095746  |  cpu time:  0.095232
wall time: 0.096550  |  cpu time:  0.096025
wall time: 0.095373  |  cpu time:  0.094902
wall time: 0.095917  |  cpu time:  0.095407
wall time: 0.095301  |  cpu time:  0.094794
wall time: 0.097900  |  cpu time:  0.097243
wall time: 0.096106  |  cpu time:  0.095624


Dmitri.
--



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]