Re: Vector problem? - How can I make the faster?
- From: cri@xxxxxxxx (Richard Harter)
- Date: Sat, 27 Oct 2007 17:03:33 GMT
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 arereading 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
.
- References:
- Vector problem? - How can I make the faster?
- From: Chun
- Vector problem? - How can I make the faster?
- Prev by Date: Re: Vector problem? - How can I make the faster?
- Next by Date: Re: Convert float to double - weird failure
- Previous by thread: Re: Vector problem? - How can I make the faster?
- Next by thread: Re: Vector problem? - How can I make the faster?
- Index(es):
Relevant Pages
|