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.
Compiler | Normal Execution | Branch Function Coverage | Decision or Line Coverage | Condition Coverage |
---|---|---|---|---|
GCC without optimization | 6840ms | 8030ms (+17.3%) | 9400ms (+37.4%) | 9830ms (+43.7%) |
GCC with optimization -Os | 4160ms | 4430ms (+6.4%) | 6180ms (+48.5%) | 6360ms (+52.8%) |
GCC with optimization -O1 | 3530ms | 4250ms (+20.3%) | 5420ms (+53.5%) | 5970ms (+69.1%) |
GCC with optimization -O2 | 3950ms | 4040ms (+2.2%) | 5080ms (+28.6%) | 5320ms (+34.6%) |
GCC with optimization -O3 | 3860ms | 4030ms (+4.4%) | 5060ms (+31%) | 5230ms (+35.4%) |
The following table shows the benchmarks in bytes.
Compiler | Native Compilation | Statement Block or Function Coverage | Decision or Line Coverage | Condition Coverage |
---|---|---|---|---|
GCC without optimization | 2128 | 3452 (+1324) | 3996 (+1868) | 4052 (+1924) |
GCC with optimization -Os | 1940 | 3196 (+1256) | 3716 (+1776) | 3760 (+1820) |
GCC with optimization -O1 | 1968 | 3172 (+1204) | 3736 (+1768) | 3792 (+1824) |
GCC with optimization -O2 | 2100 | 3452 (+1352) | 4096 (+1996) | 4160 (+2060) |
GCC with optimization -O3 | 3544 | 3548 (+4) | 4364 (+820) | 4428 (+884) |
Coco v7.2.1 ©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.