POV-Ray : Newsgroups : povray.advanced-users : Using a macro as an _argument_ for another macro : Re: Using a macro as an _argument_ for another macro Server Time
25 Apr 2024 03:00:28 EDT (-0400)
  Re: Using a macro as an _argument_ for another macro  
From: Bald Eagle
Date: 20 Jan 2023 06:40:00
Message: <web.63ca7d169f67d06e1f9dae3025979125@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:

> out of interest, what (timings) do you get when you use an already sorted array
> as inputs?


Very good question.   Good thing you asked it too.

Unsorted array:

   Bubble sorting 1000 items took 2.35 sec

Selection sorting 1000 items took 1.13 sec

Insertion sorting 1000 items took 1.57 sec

    Quick sorting 1000 items took 88.01 ms

    Shell sorting 1000 items took 112.01 ms

     Heap sorting 1000 items took 208.01 ms


Sorted array

   Bubble sorting 1000 items took 1.55 sec

Selection sorting 1000 items took 1.12 sec

Insertion sorting 1000 items took 9.00 ms

    Quick sorting ***crashes with too many nested symbol tables***

    Shell sorting 1000 items took 60.00 ms

     Heap sorting 1000 items took 222.01 ms


So, there's still more work to be done to figure out how best to avoid this sort
of thing.

I noticed while coding shell and heap that I needed to use floor () to fix some
divisions, and remove a "-1" to increase the upper bound of a loop to make sure
that everything got fully and properly sorted.   So there's obviously a number
of issue under the hood that make coding in SDL much different than coding in
C++ or other languages.

These might be some low-level operations that ought to be investigated by
someone who codes in C or C++, to compare the outputs of simple divisions, etc.

Although there are more sorting algorithms that I'd like to get converted, I'll
post the current code here for archival purposes, and for folks too look at the
code and use the algorithms in their scene files.   Caveat emptor.

- BE


Post a reply to this message


Attachments:
Download 'sorting.inc.txt' (12 KB)

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