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
20 Apr 2024 06:04:54 EDT (-0400)
  Re: Using a macro as an _argument_ for another macro  
From: Bald Eagle
Date: 19 Jan 2023 15:30:00
Message: <web.63c9a8309f67d06e1f9dae3025979125@news.povray.org>
Yes, 7am, before I even finished FIRST coffee   :O

All good ideas - I like options.

Anyway, I got that all ... sorted  :D

#macro TimeElapsed (Macro)
 #local Start = now*ms;
 Parse_String (Macro)
 #local End = now*ms;
 #local Elapsed = End-Start;

 Elapsed

#end

and now I just put the macro call in quotes, so it's a string.

#declare Speed = TimeElapsed ("#declare BubbleSorted = BubbleSort
(UnsortedArray)");



Merge sort crashed and burned with only 50 numbers, due to "Too many nested
symbol tables" - so I'll have to figure a way around that, or find some better
code to implement for that one.


I'm now on Shell sort, and behold this abomination:
#for (j = i; j >= gap && arr[j - gap] > temp; j -= gap)

I'm gonna try to divine the true meaning of that, and hopefully code up a
workable SDL version of that mess ... later.


Here's how everything is working so far:

Unsorted Array
5.627, 76.839, 25.256, 92.322, 57.569, 81.538, 25.734, 93.770, 88.249, 82.370,
7.027, 77.468, 47.888, 57.584, 36.548, 35.987, 88.602, 39.002, 60.983, 7.921,
 91.258, 84.739, 6.044, 76.053, 47.104, 10.234, 89.598, 41.787, 67.629, 94.756,
84.110, 5.537, 21.075, 5.596, 89.346, 7.762, 19.062, 7.116, 1.259, 10.329,
 1.728, 46.853, 88.009, 22.901, 94.856, 35.860, 9.052, 4.031, 37.408, 65.470,



Bubble Sorted Array
1.259, 1.728, 4.031, 5.537, 5.596, 5.627, 6.044, 7.027, 7.116, 7.762, 7.921,
9.052, 10.234, 10.329, 19.062, 21.075, 22.901, 25.256, 25.734, 35.860, 35.987,
 36.548, 37.408, 39.002, 41.787, 46.853, 47.104, 47.888, 57.569, 57.584, 60.983,
65.470, 67.629, 76.053, 76.839, 77.468, 81.538, 82.370, 84.110, 84.739, 88.009,
 88.249, 88.602, 89.346, 89.598, 91.258, 92.322, 93.770, 94.756, 94.856,

Bubble sorting 50 items took 12.00 ms.



Selection Sorted Array
1.259, 1.728, 4.031, 5.537, 5.596, 5.627, 6.044, 7.027, 7.116, 7.762, 7.921,
9.052, 10.234, 10.329, 19.062, 21.075, 22.901, 25.256, 25.734, 35.860, 35.987,
 36.548, 37.408, 39.002, 41.787, 46.853, 47.104, 47.888, 57.569, 57.584, 60.983,
65.470, 67.629, 76.053, 76.839, 77.468, 81.538, 82.370, 84.110, 84.739, 88.009,
 88.249, 88.602, 89.346, 89.598, 91.258, 92.322, 93.770, 94.756, 94.856,

Selection sorting 50 items took 7.00 ms.



Insertion Sorted Array
1.259, 1.728, 4.031, 5.537, 5.596, 5.627, 6.044, 7.027, 7.116, 7.762, 7.921,
9.052, 10.234, 10.329, 19.062, 21.075, 22.901, 25.256, 25.734, 35.860, 35.987,
 36.548, 37.408, 39.002, 41.787, 46.853, 47.104, 47.888, 57.569, 57.584, 60.983,
65.470, 67.629, 76.053, 76.839, 77.468, 81.538, 82.370, 84.110, 84.739, 88.009,
 88.249, 88.602, 89.346, 89.598, 91.258, 92.322, 93.770, 94.756, 94.856,

Insertion sorting 50 items took 9.00 ms.



Quick Sorted Array
1.259, 1.728, 4.031, 5.537, 5.596, 5.627, 6.044, 7.027, 7.116, 7.762, 7.921,
9.052, 10.234, 10.329, 19.062, 21.075, 22.901, 25.256, 25.734, 35.860, 35.987,
 36.548, 37.408, 39.002, 41.787, 46.853, 47.104, 47.888, 57.569, 57.584, 60.983,
65.470, 67.629, 76.053, 76.839, 77.468, 81.538, 82.370, 84.110, 84.739, 88.009,
 88.249, 88.602, 89.346, 89.598, 91.258, 92.322, 93.770, 94.756, 94.856,

Quick sorting 50 items took 4.00 ms.


Post a reply to this message

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