Damjan Marion | d5045e6 | 2022-04-06 21:16:37 +0200 | [diff] [blame] | 1 | /* 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 | |
| 9 | static u8 * |
| 10 | format_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 Marion | b47376f | 2023-03-15 11:42:06 +0000 | [diff] [blame^] | 27 | return format (s, "%8u", d[0]); |
Damjan Marion | d5045e6 | 2022-04-06 21:16:37 +0200 | [diff] [blame] | 28 | case 3: |
Damjan Marion | b47376f | 2023-03-15 11:42:06 +0000 | [diff] [blame^] | 29 | return format (s, "%8.2f", (f64) d[0] / c->n_ops); |
Damjan Marion | d5045e6 | 2022-04-06 21:16:37 +0200 | [diff] [blame] | 30 | case 4: |
Damjan Marion | b47376f | 2023-03-15 11:42:06 +0000 | [diff] [blame^] | 31 | return format (s, "%8u", d[2]); |
Damjan Marion | d5045e6 | 2022-04-06 21:16:37 +0200 | [diff] [blame] | 32 | case 5: |
Damjan Marion | b47376f | 2023-03-15 11:42:06 +0000 | [diff] [blame^] | 33 | 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 Marion | d5045e6 | 2022-04-06 21:16:37 +0200 | [diff] [blame] | 42 | default: |
| 43 | return s; |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | CLIB_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 Marion | b47376f | 2023-03-15 11:42:06 +0000 | [diff] [blame^] | 58 | .column_headers = CLIB_STRING_ARRAY ("Freq", "IPC", "Clks", "Clks/Op", |
| 59 | "Inst", "Inst/Op", "Brnch", "Brnch/Op", |
| 60 | "BrMiss", "BrMiss/Op"), |
Damjan Marion | d5045e6 | 2022-04-06 21:16:37 +0200 | [diff] [blame] | 61 | }; |