summaryrefslogtreecommitdiff
path: root/Microbenchmarks/STRIDED/support/cyclecount.h
blob: 4ef377e08bab6e667185cd484c3c50e540968886 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <perfcounter.h>

// Timer
typedef struct perfcounter_cycles{
    perfcounter_t start;
    perfcounter_t end;
    perfcounter_t end2;

}perfcounter_cycles;

void timer_start(perfcounter_cycles *cycles){
    cycles->start = perfcounter_get(); // START TIMER
}

uint64_t timer_stop(perfcounter_cycles *cycles){
    cycles->end = perfcounter_get(); // STOP TIMER
    cycles->end2 = perfcounter_get(); // STOP TIMER
    return(((uint64_t)((uint32_t)(((cycles->end >> 4) - (cycles->start >> 4)) - ((cycles->end2 >> 4) - (cycles->end >> 4))))) << 4);
}