blob: c2118aed974c33a5105d727f01bd1c72127a7e23 [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:
Damjan Marionb47376f2023-03-15 11:42:06 +000027 return format (s, "%8u", d[0]);
Damjan Mariond5045e62022-04-06 21:16:37 +020028 case 3:
Damjan Marionb47376f2023-03-15 11:42:06 +000029 return format (s, "%8.2f", (f64) d[0] / c->n_ops);
Damjan Mariond5045e62022-04-06 21:16:37 +020030 case 4:
Damjan Marionb47376f2023-03-15 11:42:06 +000031 return format (s, "%8u", d[2]);
Damjan Mariond5045e62022-04-06 21:16:37 +020032 case 5:
Damjan Marionb47376f2023-03-15 11:42:06 +000033 return format (s, "%8.2f", (f64) d[2] / c->n_ops);
34 case 6:
35 return format (s, "%9u", d[3]);
36 case 7:
37 return format (s, "%9.2f", (f64) d[3] / c->n_ops);
38 case 8:
39 return format (s, "%10u", d[4]);
40 case 9:
41 return format (s, "%10.2f", (f64) d[4] / c->n_ops);
Damjan Mariond5045e62022-04-06 21:16:37 +020042 default:
43 return s;
44 }
45}
46
47CLIB_PERFMON_BUNDLE (default) = {
48 .name = "default",
49 .desc = "IPC, Clocks/Operatiom, Instr/Operation, Branch Total & Miss",
50 .type = PERF_TYPE_HARDWARE,
51 .config[0] = PERF_COUNT_HW_CPU_CYCLES,
52 .config[1] = PERF_COUNT_HW_REF_CPU_CYCLES,
53 .config[2] = PERF_COUNT_HW_INSTRUCTIONS,
54 .config[3] = PERF_COUNT_HW_BRANCH_INSTRUCTIONS,
55 .config[4] = PERF_COUNT_HW_BRANCH_MISSES,
56 .n_events = 5,
57 .format_fn = format_perfmon_bundle_default,
Damjan Marionb47376f2023-03-15 11:42:06 +000058 .column_headers = CLIB_STRING_ARRAY ("Freq", "IPC", "Clks", "Clks/Op",
59 "Inst", "Inst/Op", "Brnch", "Brnch/Op",
60 "BrMiss", "BrMiss/Op"),
Damjan Mariond5045e62022-04-06 21:16:37 +020061};