-1

i need to measure dizi1's running time. I don't know how can i do exactly. Here you can see my code. How do i measure? As you can see i made a function for insortin sort

#include <stdio.h>
#include <stdlib.h>

void insort(int dizi[],int sinir)
{
    int j, sakla;
    for(int i=1; i<sinir; i++){
        sakla = dizi[i];
        j = i;
        while(j > 0 && sakla < dizi[j-1]){
            dizi[j] = dizi[j-1];
            j--;
        }
        dizi[j] = sakla;
    }
    printf("\n\nDizinin Yeni Hali\n");
    for(int i=0; i<sinir; i++)
        printf("%d\t", dizi[i]);

}

I set up an array to me use with insertion sort I need to meajure compilation time that dizi1 used

int main(){

   int dizi1[100];
   for (int i=0;i<100;++i)
    {
        dizi1[i]=rand() % 100;
        
        printf("%d\t",*(dizi1+i));
    }
   insort(dizi1,100);
   
    return 0;
}

btw so sorry about my english

  • 1
    By "compilation time" I assume you actually mean "running time". If so then the duplicate post shows that. If not then please update your question to clarify - the program itself cannot measure its own compile time. – kaylum Oct 10 '21 at 11:20

1 Answers1

0

By compilation, I assume you mean the running time

you can use the time command which is used to execute a command and print a summary of real-time, user CPU time, and system CPU time spent by executing a command when it terminates.

Akki
  • 96
  • 1
  • 7