Code coverage benchmarks

Test algorithm

The sorting algorithm used for the tests is quicksort.

Source code:

  #define SIZE 10000000
  #define NB_TESTS 4
  #include <stdio.h>
  #include <stdlib.h>
  #include <sys/times.h>
  #include <time.h>

  void sort (int array[],int size);

  main( )
  {
    int i,t ;
    long duration[NB_TESTS];
    long duration_val;
    clock_t starttime,endtime ;
    int *array;

for (t=0;t<NB_TESTS;t++)
    {
      starttime=clock();
      array=(int*)malloc(sizeof(int)*SIZE);
      for ( i = 0 ; i < SIZE ; i++ )
        array[i]=(i*7)%SIZE;
      sort(array,SIZE);
      free(array);
      endtime=clock();
      duration[t]=1000*((double)(endtime-starttime))/CLOCKS_PER_SEC;
      fprintf(stderr," %dms",duration[t]);
    }
    duration_val=duration[0];
    for (t=1;t<NB_TESTS;t++)
      if (duration_val>duration[t])
        duration_val=duration[t];
    printf("%d",duration_val);
  }

  static void quicksort ( int array[], int low, int high )
  {
    int pos  ;
    if ( low < high )
    {
      int item, i, j, t ;
      item = array[low] ;
      i = low ;
      j = high ;
      while ( i < j )
      {
        while ( array[j] > item )
          j = j - 1 ;
        while ( array[i] <= item  &&  i < j )
          i = i + 1 ;
        if ( i < j )
        {
          t = array[i] ;
          array[i] = array[j] ;
          array[j] = t ;
        }
      }
      pos = j ;
      t = array[low] ;
      array[low] = array[pos] ;
      array[pos] = t ;

      quicksort ( array, pos + 1, high ) ;
      quicksort ( array, low, pos - 1 ) ;
    }
  }

  void sort (int array[],int size)
  {
    quicksort ( array, 0, size-1 ) ;
  }

Benchmarks

The following table shows the execution benchmarks in milliseconds.

CompilerNormal ExecutionBranch Function CoverageDecision or Line CoverageCondition Coverage
GCC without optimization6840ms8030ms (+17.3%)9400ms (+37.4%)9830ms (+43.7%)
GCC with optimization -Os4160ms4430ms (+6.4%)6180ms (+48.5%)6360ms (+52.8%)
GCC with optimization -O13530ms4250ms (+20.3%)5420ms (+53.5%)5970ms (+69.1%)
GCC with optimization -O23950ms4040ms (+2.2%)5080ms (+28.6%)5320ms (+34.6%)
GCC with optimization -O33860ms4030ms (+4.4%)5060ms (+31%)5230ms (+35.4%)

The following table shows the benchmarks in bytes.

CompilerNative CompilationStatement Block or Function CoverageDecision or Line CoverageCondition Coverage
GCC without optimization21283452 (+1324)3996 (+1868)4052 (+1924)
GCC with optimization -Os19403196 (+1256)3716 (+1776)3760 (+1820)
GCC with optimization -O119683172 (+1204)3736 (+1768)3792 (+1824)
GCC with optimization -O221003452 (+1352)4096 (+1996)4160 (+2060)
GCC with optimization -O335443548 (+4)4364 (+820)4428 (+884)

Coco v7.2.0 ©2024 The Qt Company Ltd.
Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.