aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/clock.c
blob: fb6366676c59123c67ad24c09e57bb90c8dfaaf8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "cycles.h"
#include <stdio.h>

static cycle_t total_clock, last_start;

void clock_prepare(void) {
  cycle_count_config();
}

void clock_start(void) {
  last_start = get_cycle();
}

void clock_stop(void) {
  total_clock += get_cycle() - last_start;
}

cycle_t get_total_clock(void) {
  return total_clock;
}

cycle_t get_current_cycle(void) {
  return get_cycle();
}

void print_total_clock(void) {
  printf("time cycles: %lu\n", total_clock);
}

void printerr_total_clock(void) {
  fprintf(stderr, "time cycles: %lu\n", total_clock);
}