blob: b5282c517402436cbbf804f634f965c629787387 [file] [log] [blame]
Damjan Mariond5045e62022-04-06 21:16:37 +02001/* SPDX-License-Identifier: Apache-2.0
2 * Copyright(c) 2022 Cisco Systems, Inc.
3 */
4
5#include <vppinfra/format.h>
6#include <vppinfra/error.h>
7#include <vppinfra/perfmon/perfmon.h>
8
9static u8 *
10format_perfmon_bundle_default (u8 *s, va_list *args)
11{
12 clib_perfmon_ctx_t *ctx = va_arg (*args, clib_perfmon_ctx_t *);
13 clib_perfmon_capture_t *c = va_arg (*args, clib_perfmon_capture_t *);
14 u32 col = va_arg (*args, int);
15 u64 *d = c->data;
16
17 switch (col)
18 {
19 case 0:
20 if (ctx->ref_clock > 0)
21 return format (s, "%8.1f", (f64) d[0] / d[1] * (ctx->ref_clock / 1e9));
22 else
23 return s;
24 case 1:
25 return format (s, "%5.2f", (f64) d[2] / d[0]);
26 case 2:
27 if (c->n_ops > 1)
28 return format (s, "%8.2f", (f64) d[0] / c->n_ops);
29 else
30 return format (s, "%8u", d[0]);
31 case 3:
32 if (c->n_ops > 1)
33 return format (s, "%8.2f", (f64) d[2] / c->n_ops);
34 else
35 return format (s, "%8u", d[2]);
36 case 4:
37 if (c->n_ops > 1)
38 return format (s, "%9.2f", (f64) d[3] / c->n_ops);
39 else
40 return format (s, "%9u", d[3]);
41 case 5:
42 if (c->n_ops > 1)
43 return format (s, "%10.2f", (f64) d[4] / c->n_ops);
44 else
45 return format (s, "%10u", d[4]);
46 default:
47 return s;
48 }
49}
50
51CLIB_PERFMON_BUNDLE (default) = {
52 .name = "default",
53 .desc = "IPC, Clocks/Operatiom, Instr/Operation, Branch Total & Miss",
54 .type = PERF_TYPE_HARDWARE,
55 .config[0] = PERF_COUNT_HW_CPU_CYCLES,
56 .config[1] = PERF_COUNT_HW_REF_CPU_CYCLES,
57 .config[2] = PERF_COUNT_HW_INSTRUCTIONS,
58 .config[3] = PERF_COUNT_HW_BRANCH_INSTRUCTIONS,
59 .config[4] = PERF_COUNT_HW_BRANCH_MISSES,
60 .n_events = 5,
61 .format_fn = format_perfmon_bundle_default,
62 .column_headers = CLIB_STRING_ARRAY ("Freq", "IPC", "Clks/Op", "Inst/Op",
63 "Brnch/Op", "BrMiss/Op"),
64};