POV-Ray : Newsgroups : povray.unofficial.patches : megapov bug : Re: megapov bug Server Time
1 Sep 2024 22:17:35 EDT (-0400)
  Re: megapov bug  
From: Chris Huff
Date: 9 Feb 2001 19:38:31
Message: <chrishuff-B556AC.19391009022001@news.povray.org>
In article <3a840791@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:

>   Wouldn't a better and faster approach be to read all the entries into
> a temporary list and then allocate an proper-sized array, copy the 
> entries in there and then free the list?
>   I think that a temporary list would take less memory than a temporary
> dynamic array.

Maybe slightly faster at parse time, but would require one of these:

1: Changing the blend map data structure to a linked list. Pro: faster 
parsing. Cons: slower rendering, slightly more memory, more coding.

2: Adding a pointer to each element of the blend map structure, so you 
can use them in a linked list, but store them in an array for final 
usage. Pros: faster parsing, and render speed not directly affected. 
Cons: much more memory wastage, and even more coding.

3: Making a separate data type for elements of lists and of arrays, use 
the list type for the temporary list and copy to an array of the array 
type. Pros: Fast parsing speed, same rendering speed, and only 
temporarily uses more memory. Cons: Much more coding than either of the 
above, and seems like a generally clumsy solution.

If I use the resizeable array approach, it fits into the existing code 
very well (in fact, it's almost like this was planned from the start, 
but never implemented), doesn't take a lot of work to implement, and is 
only noticeably slower every once in a while, when it has to resize the 
array (for example, every 64 items). It wastes some memory temporarily, 
but that can be removed, and it doesn't amount to much anyway. (I think 
the color_map code does remove unused entries, but I'm not sure about 
the other types.)
You could even include a little optional parameter to specify the number 
of items, so the array would be allocated once. If someone really needs 
to worry about blend map memory and parse speed, they could then specify 
the number of entries in their map and the array would never have to be 
resized.
I really don't think the speed advantage of using a temporary list would 
be noticeable except in extreme cases of several hundred entries, when 
the array has to be resized multiple times...and then you would probably 
have to do a benchmark to notice it.

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.