[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: slow char({str})
From: |
Daniel J Sebald |
Subject: |
Re: slow char({str}) |
Date: |
Sun, 21 Jun 2009 21:56:50 -0500 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041020 |
Ben Abbott wrote:
On Jun 21, 2009, at 8:32 PM, Daniel J Sebald wrote:
Ben Abbott wrote:
I noticed a substantial amount of time is needed to convert a cell
string into a string
octave:50> tic; char ({repmat("a", [1, 100000])}); toc
Elapsed time is 11.9 seconds.
but ...
octave:51> tic; char ({repmat("a", [1, 100000])}{1}); toc
Elapsed time is 0.001117 seconds.
Can someone with skilled in c++ take a look?
The hard part is locating a built-in function named "char".
Dan
It is the first function defined in .../src/strfns.cc
Ah. I was searching the help text I saw running Octave, but the text has been
updated. Anyway...
Fixing it is not a task I trust myself with (as my experience with c\c+
+ is mimicing the work of others).
Yes, there is a lot there and really those knowing it best should make changes,
just to be consistent. There is a lot to follow because the
convert_to_str_internal() routine goes back to the base class. Perhaps the
other matrix types have special, more efficient member functions overriding the
base class. My first guess is that a slow point might be:
octave_value::octave_value (const Cell& c, bool is_csl)
: rep (is_csl
? dynamic_cast<octave_base_value *> (new octave_cs_list (c))
: dynamic_cast<octave_base_value *> (new octave_cell (c)))
{
}
in ov.cc. Maybe there is a lot of overhead with cells in creating stuff on the heap,
i.e., "new".
There is also this strange comment in ov.h:
// This will eventually go away, but for now it can be used to
// simplify the transition to the new octave_value class hierarchy,
// which uses octave_base_value instead of octave_value for the type
// of octave_value::rep.
#define OV_REP_TYPE octave_base_value
Maybe I've help someone narrow down things. (Or thrown a red herring.)
Dan