aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/clock.c
blob: 4ec679f69d29136e719f978c12f4d136b2706ef8 (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: %" PRcycle "\n", total_clock);
}

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