octave-maintainers
[Top][All Lists]
Advanced

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

Re: For loop benchmarks between Octave versions


From: Daniel J Sebald
Subject: Re: For loop benchmarks between Octave versions
Date: Tue, 24 Jun 2014 15:22:50 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111108 Fedora/3.1.16-1.fc14 Thunderbird/3.1.16

On 06/24/2014 02:47 AM, Daniel J Sebald wrote:

In theory, we could do something similar, i.e., just write our own
little utility program in C that implements the tests done in Octave
code. Since we are always using a C compiler, we could make the building
of this utility part of the Octave build process. For example, say the C
program (call it Cperf.c for now) generates as an output a string of
characters that lists the test and the CPU consumption:

systemcommline> Cperf
doubleForLoop/1: 181.8
doubleForLoop/a=1: 294.7
doubleForLoop/a=b: 275.6
doubleForLoop/a=a+b: 335.8
doubleForLoop/a=sin(b*i): 383.4
vectorOfSquares: 677.7
mandel: 224.9
fib: 687.6
parse_int: 2392.1
quicksort: 1244.9
pi_sum: 18236.1
rand_mat_stat: 572.8
rand_mat_mul: 515.9
printfd: 1233.3

Then, the Octave test script that implement perf.m could call the system
function Cperf to get the values and do the relative-to-C comparisons.

That seems like a pretty good comparison to me, and the benefit is we
know that Cperf is built with pretty much the same environment as Matlab
and is always present.

Actually, it might make better sense to structure Cperf.c so that it accepts inputs:

  Cperf func arg1 arg2 ...

and then returns the test result. That would simplify the parsing of the results to a simple string scan, make the program flexible for the number of times through a loop and ensure that the number of times through a loop matches whatever Octave is using. For example, here might be a string of script commands to access the C performance:

  result(end+1) = timeit ('vectorOfSquares', @vectorOfSquares, 100, 1e3);
  [stat, out] = system("Cperf vectorOfSquares 100 1000");
  cresult(end+1) = str2double(out);
  relative_perf(end+1) = result(end)/cresult(end);

Dan



reply via email to

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