Hey all:
I just finished a programming assignment (written in C) for one of my courses. The assignment involves running sorting algorithms and measuring the runtime of each. Precision is important here, as many of these will complete in a fraction of a second since I am sorting fairly small data sets. Therefore, I used the clock() function in time.h, which is typically accurate to millionths of a second.
I compiled the program on my OS X box using the built-in gcc compiler. The program ran completely fine, and I received results that showed the time being accurate to millionths of a second.
Next, I compiled and ran the program on my CS department's Linux system using GCC 4.1.2 (a newer version than on my Mac...forgot the exact version though). When I ran it, the times came out accurate only to hundredths of a second...although a tick was the same value of time (1 millionth of a second). I tried a couple of other Linux-based systems, and got the same result.
What could account for the difference here? Would it be an OS/runtime issue, or could could it be the compiler? Maybe different versions of the libraries?
Any advice appreciated. Thanks!
-scott
I just finished a programming assignment (written in C) for one of my courses. The assignment involves running sorting algorithms and measuring the runtime of each. Precision is important here, as many of these will complete in a fraction of a second since I am sorting fairly small data sets. Therefore, I used the clock() function in time.h, which is typically accurate to millionths of a second.
I compiled the program on my OS X box using the built-in gcc compiler. The program ran completely fine, and I received results that showed the time being accurate to millionths of a second.
Next, I compiled and ran the program on my CS department's Linux system using GCC 4.1.2 (a newer version than on my Mac...forgot the exact version though). When I ran it, the times came out accurate only to hundredths of a second...although a tick was the same value of time (1 millionth of a second). I tried a couple of other Linux-based systems, and got the same result.
What could account for the difference here? Would it be an OS/runtime issue, or could could it be the compiler? Maybe different versions of the libraries?
Any advice appreciated. Thanks!
-scott