octave-maintainers
[Top][All Lists]
Advanced

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

Re: odepkg: odeset profile tests


From: Jacopo Corno
Subject: Re: odepkg: odeset profile tests
Date: Thu, 04 Dec 2014 10:07:00 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0


On 02/12/2014 18:29, Carlo De Falco wrote:
Hi,

On 2 Dec 2014, at 15:49, Carlo de Falco <address@hidden> wrote:

In any case to go into core the function needs to adhere better to the coding 
standards, do I have
write access to your bitbucket repo to apply the changes? otherwise I'll just 
send you a diff.
Attached is my modified version of levenshtein.cc,
apart from some formatting the main changes are:

- add a copyright notice suitable for including in Octave core
- better check for consistency of input
- use "octave_idx_type" instead of "unsigned int" (less efficient but more 
portable)
- faster access to array elements
- add texinfo docstring

with this changes the function seems to run a bit faster on my system:

%% with levenshtein.cc
tic, opts = odeset ('AbsTol', 1e-5, ...
               'NormControl', 'on', ...
               'MaxNewtonIterations', 1e4, ...
               'MaxOrder', 4, ...
               'NewtonTol', 1e-2', ...
               'NonNegative', [1 3 5], ...
               'RelTol', 1e-5, ...
               'InitialStep', .1, ...
               'Refine', 1, ...
               'Vectorized', 'on'); toc
Elapsed time is 0.241296 seconds.

%% with levenshtein_new.cc
tic, opts = odeset ('AbsTol', 1e-5, ...
               'NormControl', 'on', ...
               'MaxNewtonIterations', 1e4, ...
               'MaxOrder', 4, ...
               'NewtonTol', 1e-2', ...
               'NonNegative', [1 3 5], ...
               'RelTol', 1e-5, ...
               'InitialStep', .1, ...
               'Refine', 1, ...
               'Vectorized', 'on'); toc
Elapsed time is 0.0917881 seconds.

I'm not sure these numbers are reliable though
as the test is quite fast anyway.

As I wrote off-list optimization of levenstein.cc
does not make much sense as the main bottleneck is
elsewhere, probably in this loop in fuzzy_logic.m :

  %# loop on every field of the list
   for i=1:1:fields_nb
     %# if the list is a cell_array of strings
     if(iscellstr(string_set))
       string2 = deblank(string_set{i}); % removing spaces at the end
     else
       %# if the list is a vector of strings
       string2 = deblank(string_set(i,:));  % removing spaces at the end
     end
     %# determining the distance by a call to levenshtein function
     values(i) = levenshtein_new (lower(string1),lower(string2),minimus); % not 
case sensitive
     minimus = min(minimus,values(i)); % updating the upper_bound to speedup 
the computation
   end

modifying levenshtein.cc to work with cell arrays of strings would probably
improve this.

I would suggest to re-run the comparison with my version of levenshtein.cc
to see if any further speedup is actually needed before spending any effort 
there
though.

these are the test run with your modifications.

TEST 1: set many options with exact naming
time : 0.058801
   #               Function Attr     Time (s)   Time (%) Calls
---------------------------------------------------------------------
  24          fuzzy_compare             0.019      35.73 10
   7                deblank             0.019      35.34 447
   3                 odeset             0.007      13.11 1
  38 ode_struct_value_check             0.001       2.11 1
  15                    max             0.001       2.03 447
  13                   find             0.001       1.48 457
  34            levenshtein             0.001       1.26 370


TEST 2: set only one option with exact naming
time : 0.015748
   #               Function Attr     Time (s)   Time (%) Calls
---------------------------------------------------------------------
   2                 odeset             0.006      41.00 1
   6                deblank             0.003      25.61 78
  23          fuzzy_compare             0.002      17.28 1
  37 ode_struct_value_check             0.001       6.46 1
  14                    max             0.000       1.54 78
  12                   find             0.000       1.03 79
  20         __fieldnames__             0.000       1.01 2



TEST 3: set many options with many typos
time : 0.063206
   #               Function Attr     Time (s)   Time (%) Calls
---------------------------------------------------------------------
  24          fuzzy_compare             0.021      36.66 10
   7                deblank             0.020      34.15 457
   3                 odeset             0.007      12.75 1
  42 ode_struct_value_check             0.001       1.96 1
  15                    max             0.001       1.94 457
  13                   find             0.001       1.50 467
  40                warning             0.001       1.18 10


TEST 4: set only one option with small typo
time : 0.017849
   #               Function Attr     Time (s)   Time (%) Calls
---------------------------------------------------------------------
   2                 odeset             0.007      42.70 1
   6                deblank             0.004      23.83 79
  23          fuzzy_compare             0.003      16.55 1
  41 ode_struct_value_check             0.001       6.00 1
  14                    max             0.000       1.62 79
  20         __fieldnames__             0.000       1.58 2
  12                   find             0.000       1.06 80



Furthermore, it seems fuzzy_compare would need to go into Octave core as well, 
but as it is now
it is absolutely not acceptable, formatting, documentation and comments
(too many useless and annoyingly verbose comments don't make the code more 
readable)
all need a lot of improvement.

I will take care of that.

c.

Jacopo

--

Jacopo Corno M.Sc.
Technische Universität Darmstadt
Graduate School of Computational Engineering
Dolivostraße 15
64293 Darmstadt / Germany

Office: S4|10-232
Phone: +49 6151 16 - 76877
Email: address@hidden




reply via email to

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