Does comparison of floating point numbers takes (considerably) longer time than comparison of Integers in C?
I just wrote a C program of heap sort to sort floating point numbers.
I am on ubuntu 14.04 and I used
time command to check the time taken by this program for sorting 50, 5000 and 50000 random numbers and then I just changed all
int and again checked time for 50, 5000 and 5000 numbers and statistics are as follows:
$ time ./heap 50 < input.txt real 0m0.003s user 0m0.001s sys 0m0.002s $ time ./temp 50 < input.txt real 0m0.003s user 0m0.001s sys 0m0.002s $ time ./heap 5000 < input.txt real 0m0.008s user 0m0.007s sys 0m0.002s $ time ./temp 5000 < input.txt real 0m0.005s user 0m0.004s sys 0m0.001s $ time ./heap 50000 < input.txt real 0m0.030s user 0m0.028s sys 0m0.002s $ time ./temp 50000 < input.txt real 0m0.027s user 0m0.026s sys 0m0.002s $ time ./heap 500000 < input.txt real 0m0.263s user 0m0.259s sys 0m0.003s $ time ./temp 500000 < input.txt real 0m0.219s user 0m0.216s sys 0m0.003s
Here heap is the executable of floating point heapsort and temp is the executable of Integer number heapsort.
As we can see there is noticeable difference in running times? What is the reason? I can upload the codes if needed.