Browse Source

Update benchmark statistical time function

The function gettimeofday does not count the time,when testing the axpy small data volume use case.
Use the function clock_gettime to replace the gettimeofday function to count the time.
tags/v0.3.10^2
MacChen02 GitHub 5 years ago
parent
commit
917d243580
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions
  1. +5
    -5
      benchmark/axpy.c

+ 5
- 5
benchmark/axpy.c View File

@@ -128,7 +128,7 @@ int main(int argc, char *argv[]){
int to = 200;
int step = 1;

struct timeval start, stop;
struct timespec start, stop;
double time1,timeg;

argc--;argv++;
@@ -175,13 +175,13 @@ int main(int argc, char *argv[]){
for(i = 0; i < m * COMPSIZE * abs(inc_y); i++){
y[i] = ((FLOAT) rand() / (FLOAT) RAND_MAX) - 0.5;
}
gettimeofday( &start, (struct timezone *)0);
clock_gettime( CLOCK_REALTIME, &start);

AXPY (&m, alpha, x, &inc_x, y, &inc_y );

gettimeofday( &stop, (struct timezone *)0);
clock_gettime( CLOCK_REALTIME, &stop);

time1 = (double)(stop.tv_sec - start.tv_sec) + (double)((stop.tv_usec - start.tv_usec)) * 1.e-6;
time1 = (double)(stop.tv_sec - start.tv_sec) + (double)((stop.tv_nsec - start.tv_nsec)) * 1.e-9;

timeg += time1;

@@ -190,7 +190,7 @@ int main(int argc, char *argv[]){
timeg /= loops;

fprintf(stderr,
" %10.2f MFlops %10.6f sec\n",
" %10.2f MFlops %10.9f sec\n",
COMPSIZE * COMPSIZE * 2. * (double)m / timeg * 1.e-6, timeg);

}


Loading…
Cancel
Save