Commit 91a330bc1adf3d218185bba00d8694b822afd756

Authored by Aravind Kumar
1 parent e453ede6a2
Exists in master

CPU Measurement # 1 Loop Overhead

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

cpu/loop_overhead_time.c View file @ 91a330b
  1 +#include <stdio.h>
  2 +
  3 +int main()
  4 +{
  5 + int time1, time2, sum=0;
  6 + int i;
  7 + int avg = 0;
  8 + asm volatile("mrc p15, 0, %0, c9, c14, 0" : "=r" (i));
  9 +
  10 + while(sum < 100) {
  11 + asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time1));
  12 + for (i = 0; i < 1000; i++);
  13 + asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time2));
  14 + sum++;
  15 + avg += (time2 - time1 - 5);
  16 + printf("Loop overhead: %u\n", avg/(1000));
  17 + }
  18 +}
cpu/loop_overhead_time.o View file @ 91a330b

No preview for this file type