Commit 951d6ba82ccb8199ce958cc857ff9f4753c808d7

Authored by Aravind Kumar
1 parent 5d73e140ef
Exists in master

GettimeofDay overhead

Showing 2 changed files with 21 additions and 0 deletions Side-by-side Diff

cpu/gettimeofday_overhead.c View file @ 951d6ba
  1 +#include <stdio.h>
  2 +#include <sys/time.h>
  3 +
  4 +int main()
  5 +{
  6 + int time1, time2, sum=0;
  7 + int i;
  8 + float avg = 0.0;
  9 + asm volatile("mrc p15, 0, %0, c9, c14, 0" : "=r" (i));
  10 + printf("Get Time of Day overhead: \n");
  11 + struct timeval tv;
  12 +
  13 + while(sum < 100) {
  14 + asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time1));
  15 + gettimeofday(&tv, NULL);
  16 + asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time2));
  17 + avg = (time2 - time1);
  18 + sum++;
  19 + }
  20 + printf("%f", avg);
  21 +}
cpu/gettimeofday_overhead.o View file @ 951d6ba

No preview for this file type