[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #52858] Consider using C gnulib clock_gettime(
From: |
Dan Sebald |
Subject: |
[Octave-bug-tracker] [bug #52858] Consider using C gnulib clock_gettime() for Octave cputime() |
Date: |
Wed, 10 Jan 2018 12:45:00 -0500 (EST) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0 |
Follow-up Comment #1, bug #52858 (project octave):
Continuing from this post:
https://savannah.gnu.org/bugs/?52809#comment22
I've implemented the example loops with cputime and tic/toc as functions:
function tdiff=bm_for_loop()
a = 1; b = 1; t0=cputime; for i=1:1000; for j=1:1000; a = a + b + 123.0; end;
end; t1=cputime; tdiff = t1 - t0
function t1=bm_for_loop2()
a = 1; b = 1; t0=tic; for i=1:1000; for j=1:1000; a = a + b + 123.0; end;
end;
t1=toc(t0); t1
As results, I'm seeing:
octave:9> tl=zeros(20,1); for i=1:20; tl(i) = bm_for_loop; end;
tdiff = 2.7720
tdiff = 2.8040
tdiff = 2.7960
tdiff = 2.8000
tdiff = 2.8000
tdiff = 2.8000
tdiff = 2.8000
tdiff = 2.8000
tdiff = 2.8160
tdiff = 2.8000
tdiff = 2.8000
tdiff = 2.7960
tdiff = 2.7960
tdiff = 2.8000
tdiff = 2.8000
tdiff = 2.8040
tdiff = 2.7960
tdiff = 2.8160
tdiff = 2.7960
tdiff = 2.8000
octave:10> tl2=zeros(20,1); for i=1:20; tl2(i) = bm_for_loop2; end;
t1 = 2.7467
t1 = 2.8181
t1 = 2.8147
t1 = 2.8200
t1 = 2.8073
t1 = 2.8180
t1 = 2.8186
t1 = 2.8184
t1 = 2.8127
t1 = 2.8237
t1 = 2.8149
t1 = 2.8078
t1 = 2.8130
t1 = 2.8135
t1 = 2.8145
t1 = 2.8168
t1 = 2.8243
t1 = 2.8114
t1 = 2.8069
t1 = 2.8138
octave:11> mean(tl)
ans = 2.7996
octave:12> std(tl)
ans = 0.0085987
octave:13> mean(tl2)
ans = 2.8118
octave:14> std(tl2)
ans = 0.016044
octave:15> mean(tl2) - mean(tl)
ans = 0.012160
I don't think I can conclude there is a statistically significant difference
from that, given there could be slightly different CPU usage between
invocations.
I do believe though that there could be a difference in the above link,
statistically speaking, i.e.,
octave:1> bm_for_loop
ans = 4.6840
octave:2> bm_for_loop
ans = 4.6640
octave:3> bm_for_loop
ans = 4.6240
octave:4> bm_for_loop2
t1 = 4.4830
octave:5> bm_for_loop2
t1 = 4.5830
octave:6> bm_for_loop2
t1 = 4.4962
I wonder if the issue there is that, in fact, the test is physically taking
less time to operate than what cputime() reports because cputime() might
include a combination of CPU usage from more than one processor core. That
is, perhaps some small aspect of this test can be shifted to a second CPU in a
multi-threaded environment.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?52858>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #52858] Consider using C gnulib clock_gettime() for Octave cputime(), Dan Sebald, 2018/01/10
- [Octave-bug-tracker] [bug #52858] Consider using C gnulib clock_gettime() for Octave cputime(),
Dan Sebald <=
- [Octave-bug-tracker] [bug #52858] Consider using C gnulib clock_gettime() for Octave cputime(), Mike Miller, 2018/01/11
- [Octave-bug-tracker] [bug #52858] Consider using C gnulib clock_gettime() for Octave cputime(), John W. Eaton, 2018/01/11
- [Octave-bug-tracker] [bug #52858] Consider using C gnulib clock_gettime() for Octave cputime(), Mike Miller, 2018/01/11
- [Octave-bug-tracker] [bug #52858] Consider using C gnulib clock_gettime() for Octave cputime(), John W. Eaton, 2018/01/11
- [Octave-bug-tracker] [bug #52858] Consider using C gnulib clock_gettime() for Octave cputime(), Mike Miller, 2018/01/11
- [Octave-bug-tracker] [bug #52858] Consider using C gnulib clock_gettime() for Octave cputime(), Michael Godfrey, 2018/01/12