Re: Benchmark: STL's list vs. hand-coded one
- From: Mark Borgerson <mborgerson@xxxxxxxxxxx>
- Date: Thu, 22 Nov 2007 21:23:18 -0800
In article <fi4taa$ljq$3@xxxxxxxxxxxxxxxxxx>,
jyrki@xxxxxxxxxxxxxxxxxxxxxxx says...
nospam <nospam@xxxxxxxxxxxxxx> wrote:
Given that it takes just a few lines of code to get access to
64MB of RAM in a single big buffer, I see no particular
point in a lot of new() and free(0) or malloc() statements in
a program written for a modern PC.
And having 64MB buffer allocated you will need to write your own new(),
free(), or malloc() implementations to manage memory in the buffer and do
you *know* they are going to be more efficient than the library and OS code
you are avoiding?
Since this discussion started about a lexer, at least I find it quite
unlikely that a custom memory allocator can be any faster than a generic
one; a lexer simply needs a generic allocator (unless all the tokens of
the language are, let's say fixed to sizeof(char).. :)).
Hey, memory is cheap. Simple fix each element to a defined maximum
size, say 100 bytes. Then allocate enough memory for an array of
64,000 of those elements. (64,000 * 100 bytes ~= 64MBytes.).
How much simpler than
char *nextptr = &bigbuf[0];
elemptr = &nextptr;
nextptr+= 100;
can your hypothetical generic memory allocator get???
The above two lines of C should compile down to about
two instructions on a 32-bit processor. You can't get
much more efficient than that.
Mark Borgerson
.
- Follow-Ups:
- Re: Benchmark: STL's list vs. hand-coded one
- From: Jyrki Saarinen
- Re: Benchmark: STL's list vs. hand-coded one
- References:
- Benchmark: STL's list vs. hand-coded one
- From: Jyrki Saarinen
- Re: Benchmark: STL's list vs. hand-coded one
- From: Wilco Dijkstra
- Re: Benchmark: STL's list vs. hand-coded one
- From: Jyrki Saarinen
- Re: Benchmark: STL's list vs. hand-coded one
- From: Wilco Dijkstra
- Re: Benchmark: STL's list vs. hand-coded one
- From: Jyrki Saarinen
- Re: Benchmark: STL's list vs. hand-coded one
- From: Wilco Dijkstra
- Re: Benchmark: STL's list vs. hand-coded one
- From: Mark Borgerson
- Re: Benchmark: STL's list vs. hand-coded one
- From: Everett M. Greene
- Re: Benchmark: STL's list vs. hand-coded one
- From: Mark Borgerson
- Re: Benchmark: STL's list vs. hand-coded one
- From: nospam
- Re: Benchmark: STL's list vs. hand-coded one
- From: Jyrki Saarinen
- Benchmark: STL's list vs. hand-coded one
- Prev by Date: Re: Benchmark: STL's list vs. hand-coded one
- Next by Date: Re: Benchmark: STL's list vs. hand-coded one
- Previous by thread: Re: Benchmark: STL's list vs. hand-coded one
- Next by thread: Re: Benchmark: STL's list vs. hand-coded one
- Index(es):
Relevant Pages
|
Loading