calculate sorting algorith completion times

hello i need help with calculating the time it takes for sorting algorithms to complete their sorting. i don't know if this is in a library or is it a switch that comes in the compiler or what. the sorting algorithm will be run multiple times with different array sizes and random numbers. if it helps also including the insertsort

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void insertionSort(unsigned int array[],int length)
{
float temp;
for (int i=1;i<length;i++)
	{
	temp=array[i];
	int j=i-1;
	while (array[j]>temp && j>=0)
		{
		array[j+1]=array[j];
		j--;
		}
	array[j+1]=temp;
	}
}
Assuming you are looking for time complexity, it looks like O(n^2) as worst and O(n) at best.
big O notation is not what i want, also the above code doesnt seem to be working for big arrays for me just small ones.
it probably doesn’t work for large arrays because insertion sort is very inefficient for larger arrays.

the <ctime> library has some functions that will help you.
http://www.cplusplus.com/reference/clibrary/ctime/
Topic archived. No new replies allowed.