Re: object replication

new topic     » goto parent     » topic index » view thread      » older message » newer message

>>> Below is a routine to copy any object "exactly". But my
>>> intent is really to release the original object from any pointers.
>>> This will have speed benefits.


It didnt do that.
This trick would:

function duplicate (object x)

  -- Depending on how smart ex.exe is:
    x = x + 0
  -- If it is too smart:
    x = x + 1
    x = x - 1

    return x
end function

>Rob replied:
>
>>Can you create an example that shows these alleged speed benefits?
>>I really don't see the point to this.
>
>Actually I thought that I did have an example of speed degradation in
>sequences. You see, a few months ago I wrote a small program to provide
some
>useful data for the office that I work at. Basically, the program read in
>two lists of  data and then amalgamated them using a common attribute, ie
>the clients ID number. The original lists contained about 4000 entries and
>after amalgamation 1500. Now, when I first ran this program I observed the
>counter on the screen. Initially the counter was updating very quickly but
>it soon slowed down and continued doing so until all records have been
>processed. I PRESUMED that this was due to the pointer-istic (if such a
term
>be allowed) nature of the sequence in Euphoria. Well, I have spent a couple
>hours recreating this program and, you know, I cannot duplicate the
anomaly.
>Whats more, the entire program now takes only 3 seconds to run. This is
>somewhat different from the minute or so that it required previously.



There are two possible explenations for this, that I can come up with:
* The file and program were now still in the cache: this speed things up
alot.
    Were you using append () or & ??

* You forced ex.exe to work with two different sequence, in such way, it has
to reproduce every sequence every time, these things are esspecially nasty
in recursion. Try not to use an sequence after you copied it to another
sequence.

As it sounds I think the speed benefit was, that ex.exe figured it did NOT
have to copy the sequence at all. Since the old sequence wasnt used anymore.
You can try the above. Add the routine to your program and use it. It will
enormously slow down your program. That is my guess.

PS. There *are* reasons to be found for such a routine to exist though.
Whenever the object duplication is going to happen, and you want it to
happen at some other time. Before the game starts, when it is still
displaying the 'loading' text on the screen. I would like it if Euphoria
optimized around statement blocks like it already does a bit with the
for-loop.

Ralf

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu