Click here to Skip to main content
15,887,746 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Best coding practice. Pin
Member 41945937-Apr-09 14:40
Member 41945937-Apr-09 14:40 
GeneralRe: Best coding practice. Pin
Luc Pattyn7-Apr-09 15:21
sitebuilderLuc Pattyn7-Apr-09 15:21 
GeneralRe: Best coding practice. Pin
Member 41945937-Apr-09 16:23
Member 41945937-Apr-09 16:23 
GeneralRe: Best coding practice. Pin
Member 419459310-Apr-09 19:55
Member 419459310-Apr-09 19:55 
GeneralRe: Best coding practice. Pin
Luc 64801111-Apr-09 0:39
Luc 64801111-Apr-09 0:39 
GeneralRe: Best coding practice. Pin
Member 419459311-Apr-09 5:51
Member 419459311-Apr-09 5:51 
GeneralRe: Best coding practice. Pin
Luc 64801111-Apr-09 6:18
Luc 64801111-Apr-09 6:18 
GeneralRe: Best coding practice. Pin
Member 419459315-Apr-09 8:29
Member 419459315-Apr-09 8:29 
Luc,

I found an error in the Descending Descending where I had supplied the ascending
data instead of the descending data, and I corrected that. I also modified the
timing procedure to create all of the data first, then execute the tests, and
then added a loop to run all of the tests 10 times. I added code to call
SetPriorityClass to set the priority to HIGH_PRIORITY_CLASS. I added code to
put the start of each procedure on an aligned 16 location to make sure that the
same code in the ascending and descending routines stayed on the same relative
boundaries to avoid differences in the hardware branch predictions - this would
only cause a 1 or 2 cycle difference in time, but with 1,000,000,000 *
1,000,000,000 compares it will make a difference - note that something as small
as a 26 record sort takes 109 compares and 14 exchanges.

I put the loops for the left scan and the right scan on 16 BYTE boundaries to
aid in the hardware branch prediction.

I modified the code to clean up the floating jump on condition tests (had to
re-order my register usages to free up eax, then debug and re-test).

I modified the test code to add a timing test for floats.

The following are the results from the first two iterations of the tests (almost
the same times as for DWORDS):

uilding Ascending data.
Building Descending data.
Building Random data.
                                                                         Floating tests         DWORD tests 
1024*1024 Ascending Floats sorted 1024 times Ascending, time in msec:    32359, good compare.   32068, good compare.
1024*1024 Ascending Floats sorted 1024 times Descending, time in msec:   36407, good compare.   37310, good compare.
1024*1024 Descending Floats sorted 1024 times Ascending, time in msec:   36749, good compare.   37276, good compare.
1024*1024 Descending Floats sorted 1024 times Descending, time in msec:  36674, good compare.   38611, good compare.
1024*1024 Random Floats sorted 1024 times Ascending, time in msec:      130539, good compare.  132599, good compare.
1024*1024 Random Floats sorted 1024 times Descending, time in msec:     131883, good compare.  131187, good compare.

1024*1024 Ascending Floats sorted 1024 times Ascending, time in msec:    32005, good compare.   32005, good compare.
1024*1024 Ascending Floats sorted 1024 times Descending, time in msec:   37254, good compare.   36943, good compare.
1024*1024 Descending Floats sorted 1024 times Ascending, time in msec:   37126, good compare.   35773, good compare.
1024*1024 Descending Floats sorted 1024 times Descending, time in msec:  37446, good compare.   37359, good compare.
1024*1024 Random Floats sorted 1024 times Ascending, time in msec:      130639, good compare.  133531, good compare.
1024*1024 Random Floats sorted 1024 times Descending, time in msec:     130431, good compare.  131447, good compare.


Dave.
GeneralRe: Best coding practice. Pin
Luc 64801115-Apr-09 8:39
Luc 64801115-Apr-09 8:39 
GeneralRe: Best coding practice. Pin
Member 419459315-Apr-09 9:45
Member 419459315-Apr-09 9:45 
QuestionRotation of Bitmap Pin
CodeOfLife5-Apr-09 16:21
CodeOfLife5-Apr-09 16:21 
AnswerRe: Rotation of Bitmap [modified] Pin
Luc Pattyn5-Apr-09 16:30
sitebuilderLuc Pattyn5-Apr-09 16:30 
GeneralRe: Rotation of Bitmap Pin
CodeOfLife6-Apr-09 6:37
CodeOfLife6-Apr-09 6:37 
GeneralRe: Rotation of Bitmap Pin
Luc Pattyn6-Apr-09 6:59
sitebuilderLuc Pattyn6-Apr-09 6:59 
QuestionCreating RSOM from SOM Pin
Jasmine Pomelo4-Apr-09 14:04
Jasmine Pomelo4-Apr-09 14:04 
QuestionRe: Creating RSOM from SOM Pin
CPallini6-Apr-09 21:39
mveCPallini6-Apr-09 21:39 
AnswerRe: Creating RSOM from SOM Pin
Jasmine Pomelo9-Apr-09 9:38
Jasmine Pomelo9-Apr-09 9:38 
QuestionSingle Elimination - Tournament Brackets Pin
aslamc2-Apr-09 9:32
aslamc2-Apr-09 9:32 
AnswerRe: Single Elimination - Tournament Brackets Pin
Alan Balkany3-Apr-09 4:00
Alan Balkany3-Apr-09 4:00 
QuestionTree algo Pin
dfreeser2-Apr-09 5:58
dfreeser2-Apr-09 5:58 
AnswerRe: Tree algo Pin
Alan Balkany3-Apr-09 3:43
Alan Balkany3-Apr-09 3:43 
GeneralRe: Tree algo Pin
dfreeser3-Apr-09 5:15
dfreeser3-Apr-09 5:15 
GeneralRe: Tree algo Pin
Alan Balkany3-Apr-09 5:42
Alan Balkany3-Apr-09 5:42 
GeneralRe: Tree algo Pin
dfreeser3-Apr-09 6:02
dfreeser3-Apr-09 6:02 
GeneralRe: Tree algo Pin
Alan Balkany3-Apr-09 6:16
Alan Balkany3-Apr-09 6:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.