Re: Vector problem? - How can I make the faster?



On Fri, 26 Oct 2007 22:49:00 -0700, Chun <chun.tse@xxxxxxxxx>
wrote:

Hello,

I've written some code in C++ to decode a binary file. First I read
the contents of the file and then create an index to each record and
field in the file. Then I have method to dump to stdio or I used
populate TCL structures for use in tcl scripts.

When I run on windows then it decodes a large file faily quickly.
However, when I run on Sun solaris then it "stalls" every now before
finally completing. Someone said that this is to do with me using
vectors and the "stall" was the vector algorithm finding more memory
to increase it's size.

I've attached my code. Could someone comment on it and where it could
be improved? I'm particular interested in performance "tricks".

Thanks in advance
Michael


Snip code. I don't want to dig through a large mass of C++ code.
From your description, however, it sounds as though you are
reading the whole file into memory, the problem being that when
you read a new record the previous records still exist. Check to
make sure that you are freeing the space for records once you
have indexed them. (It is somewhat faster to read the records
into an extensible buffer but that may be awkward to do in C++.)

The other area to look at is the output procedures. There
shouldn't be a problem if you are just dumping to stdio. However
there could be a problems with populatng the TCL structures.
Here you have a simple check: Compare execution times for the
two alternatives.

The thing is that the task you describe should have a small
memory footprint; it sounds as though your program has a large
footprint.


Richard Harter, cri@xxxxxxxx
http://home.tiac.net/~cri, http://www.varinoma.com
In the fields of Hell where the grass grows high
Are the graves of dreams allowed to die
.



Relevant Pages

  • Re: 128 BIT 32x4 PROMS?
    ... A memory decode prom on ... is on CPU card) has blown and was running hot. ... A15 bank select on the 48k card but hit a race problem. ...
    (sci.electronics.repair)
  • Re: 128 BIT 32x4 PROMS?
    ... A memory decode prom on ... is on CPU card) has blown and was running hot. ... A15 bank select on the 48k card but hit a race problem. ...
    (sci.electronics.repair)
  • Re: Large image
    ... to run the device out of memory long before it's fully in memory. ... Correct, that's why I said that he should write a "read and decode" method, ... essentially the equivalent of "new Bitmap ". ... But is it possible to load for instance the upper left 1000*1000 ...
    (microsoft.public.dotnet.framework.compactframework)
  • 128 BIT 32x4 PROMS?
    ... Proms are Harris semiconductor but I've lost the orignal chip. ... A memory decode prom on ... is on CPU card) has blown and was running hot. ...
    (sci.electronics.repair)