Visual Basic Explorer
Visual Basic Explorer
 Navigation
 Home


 Coding
 Source Code

 FAQ Center

 VB Tips

 Downloads

 ToolBox

 Tutorials

 VB Games

 VB News

 VB Award

 VB Forums



 Affiliates
 Planet Source Code

 Rent a Coder

 DirectX4VB


 Misc
 Search

 Feedback

 Advertise

 About


Need to hire
a VB coder?

Please support our sponsor:

 Home 
 Site Map 
 Forums 
 News 
 Feedback 

Sorting Timer

A Visual Basic® Tutorial


Running the Timer


Once you have the controls placed on the form and copied the code to the code window, Press F5 to run the timer. Immediately you will see this window and be able to time the sorts by clicking on Timings.

Overview
Copy the Code
The Controls Across the Top

Randomize

Left click on this button to populate the array with integers, duplicates allowed. Right click to randomize with all different numbers - no duplicates. It may take a little while to randomize large arrays. The backcolor of the timer will turn to brown when done.


Ascend

This button toggles ascend with descend to indicate the direction in which the array will be sorted. After an array is sorted, change direction and see how long it takes to sort when the array is completely ordered in the opposite direction. You might also check to see how long the various methods take to sort an array that is already sorted (in the same direction).


Timings

Click this to perform the timings. The time for each method included will be displayed in milliseconds (1000 = 1 second) as the individual sorts complete. Note that each method will be sorting the exact same array (element values in the same order) to give true comparability.

The timing uses an API call and includes no DoEvents while sorting for the most accurate timing. That means, however, that your computer will seem to lock up while sorting. While running from the VB editor, you back stop at any time by pressing [Ctrl][Break].


Elements

Enter a different number in the textbox to change the number of elements to be sorted (minimum 100, maximum 32766). After changing the value (and pressing enter or tabbing) the backcolor will change to orange while the new size array is being populated and randomized. Wait for it to turn brown again.

For elements exceeding 10,000, you may want to include just the fastest sorting methods (Count, Heap, Quick, and Shell). Refer to the my timings chart below.


The Command Buttons down the Side

Include

Include buttons toggle with exclude allowing you to time only certain sorting methods. Right click to quickly select only one method.


Confirm

Sorted arrays are checked after each sort to ascertain that they are truly ordered (!order! if failed). Further a checksum is verified to be sure all the numbers are there (!total! if failed). If both checks are passed then this column will show the word success. The array is ordered if the last timed sort succeeds. This allows you to toggle ascend and sort the array with elements in completely reversed order.


My timings on these methods from the VB editor on my AMD K6-450 computer

                                    (max)
                 1000     10000     32766 ELEMENTS

  Bubble         1120    116080   1255291 *
  Bi-Bubble       737     72746    775511
  Heap            111      1518      5658
  Insertion       475     46924    500731
  Merge           575     52436    554741
  Quick            31       405      1443
  Selection       992     99469   1069354
  Shell            77      1121      4220
  Interpolate     282     26752    325239
  Count             5        37       119

  * Note 1255291 is about 21 minutes




Home | About | What's New | Source Code | FAQ | Tips & Tricks | Downloads | ToolBox | Tutorials | Game Programming | VB Award | Search | VB Forums | Feedback | VBNews | Copyright & Disclaimer | Advertise | Privacy Policy |

Quick searches: Site Search | Advanced Site Search 

Copyright 2002 by Exhedra Solutions, Inc.
By using this site you agree to its terms and conditions
VB Explorer and VBExplorer.com are trademarks of Exhedra Solutions, Inc.