KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
profiler.c
1 /*
2  * KM3NeT CLB v2 Firmware
3  * ----------------------
4  *
5  * Copyright 2012-2015 KM3NeT Collaboration
6  *
7  * All Rights Reserved.
8  *
9  *
10  * File : profiler.c
11  * Created : 4 mrt. 2015
12  * Author : Vincent van Beveren
13  */
14 #include "dbg/profiler.h"
15 
16 #include <stdio.h>
17 
18 void profStop(ProfEntry * entry) {
19  uint32_t elapsed = entry->t - ticks();
20  entry->time += elapsed;
21  entry->count++;
22 }
23 
24 void profTable(ProfEntry * entry, int lines) {
25  puts("Name Tot [ms] Count Avr [us]");
26  puts("---------------------- ---------- ---------- --------");
27 
28  uint32_t avr;
29 
30  while (lines > 0) {
31  avr = entry->count > 0 ? (entry->time * 1000) / entry->count : 0;
32  printf("%22s %10lu %10lu %8lu\n", (uint32_t)entry->name, entry->time, entry->count, avr);
33  entry++;
34  lines--;
35  }
36 }
Definition: profiler.h:19
static uint32_t ticks()
Nr of ticks since device start up.
Definition: ticks.h:37