[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #63410] mean input validation misses invalid i
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #63410] mean input validation misses invalid inputs for dim |
Date: |
Thu, 24 Nov 2022 09:13:48 -0500 (EST) |
Follow-up Comment #7, bug #63410 (project octave):
I noted the same code pattern as Markus, but hadn't been troubled enough to
investigate it. I do think clarity for future maintainer's is a high
priority.
Whether there is a performance difference between calling "all" implicitly or
explicitly is subject to experimentation. My hypothesis before testing was
this would make very little difference at all. But, this is why one needs to
run the experiment because, in fact, calling "all" explicitly is 35% faster on
my machine and a very clear winner.
Test code I used is attached as bm_implicit_all.m and reproduced here:
N = 1e3;
data = ones (1e6, 1);
tic;
for i = 1:N
if (data)
endif
endfor
bm1 = toc
tic;
for i = 1:N
if (all (data))
endif
endfor
bm2 = toc
And a sample test run is
bm_implicit_all
bm1 = 1.9310
bm2 = 1.2500
octave:14> pctchg (bm1, bm2)
ans = -35.266
The function "pctchg" is my own local function that calculates the percentage
change of two values.
Given both the clarity and performance benefits I made the change proposed by
Markus here: http://hg.savannah.gnu.org/hgweb/octave/rev/c154cc05cd1f
(file #54010)
_______________________________________________________
Additional Item Attachment:
File name: bm_implicit_all.m Size:0 KB
<https://file.savannah.gnu.org/file/bm_implicit_all.m?file_id=54010>
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?63410>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #63410] mean input checking misses dim = Inf, poor error messaging, Nicholas Jankowski, 2022/11/23
- [Octave-bug-tracker] [bug #63410] mean input validation misses invalid inputs for dim, Nicholas Jankowski, 2022/11/23
- [Octave-bug-tracker] [bug #63410] mean input validation misses invalid inputs for dim, Nicholas Jankowski, 2022/11/23
- [Octave-bug-tracker] [bug #63410] mean input validation misses invalid inputs for dim, Nicholas Jankowski, 2022/11/23
- [Octave-bug-tracker] [bug #63410] mean input validation misses invalid inputs for dim, Rik, 2022/11/23
- [Octave-bug-tracker] [bug #63410] mean input validation misses invalid inputs for dim, Rik, 2022/11/23
- [Octave-bug-tracker] [bug #63410] mean input validation misses invalid inputs for dim, Markus Mützel, 2022/11/24
- [Octave-bug-tracker] [bug #63410] mean input validation misses invalid inputs for dim, Nicholas Jankowski, 2022/11/24
- [Octave-bug-tracker] [bug #63410] mean input validation misses invalid inputs for dim, Markus Mützel, 2022/11/24
- [Octave-bug-tracker] [bug #63410] mean input validation misses invalid inputs for dim,
Rik <=
- [Octave-bug-tracker] [bug #63410] mean input validation misses invalid inputs for dim, Nicholas Jankowski, 2022/11/24