Michael's Blogger Shower

Welcome to my Google sponsored shower! If you want to be able to post comments, contact me. :)

Saturday, April 16, 2016

Sort DLL

I took this elective in college called Advanced Windows programing. It was the another Visual C++ class taught by these adjuncts from Intel. It was a fun set of classes.

When we got to creating Dynamic Linked Libraries or DLLs, they had a friendly competition for the project lesson. We had to create a DLL that exposed two functions: one to get an array  of integers and another to sort those values. The student with the fastest sort function would win a candy bar.


There were 5 winners. One guy was disqualified because he sorted the array in the function that accepted the array. Some people did not care and just did one of the many sorting algorithms like the bubble sort. Three people used the C library function qsort. It basically is a quick sort.


I was asked if I did any optimizations to my code. When i admitted I had not, I was given a Snickers bar. I guess it was funny, I did not do much and came in 3rd. The 4th and 5th place winner had done some work in the comparison functions used by qsort and apparently was slower than a simple comparison of integers. 

The second place winner had written his sort function in Assembly. It must have been a serious let down to do all that work and lose. The 1st place winner had used the sorting algorithm i n the Active Template Library.

“Never write your own algorithm when you can use a vetted and optimized one.” the guy proudly boasted.

0 Comments:

Post a Comment

<< Home