#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
#include <linux/string.h>
#include <linux/time64.h>
#include <math.h>
#include "color.h"
#include "counts.h"
#include "evlist.h"
#include "evsel.h"
#include "stat.h"
#include "top.h"
#include "thread_map.h"
#include "cpumap.h"
#include "string2.h"
#include <linux/ctype.h>
#include "cgroup.h"
#include <api/fs/fs.h>
#include "util.h"
#define CNTR_NOT_SUPPORTED "<not supported>"
#define CNTR_NOT_COUNTED "<not counted>"
static void print_running(struct perf_stat_config *config,
u64 run, u64 ena)
{
if (config->csv_output) {
fprintf(config->output, "%s%" PRIu64 "%s%.2f",
config->csv_sep,
run,
config->csv_sep,
ena ? 100.0 * run / ena : 100.0);
} else if (run != ena) {
fprintf(config->output, " (%.2f%%)", 100.0 * run / ena);
}
}
static void print_noise_pct(struct perf_stat_config *config,
double total, double avg)
{
double pct = rel_stddev_stats(total, avg);
if (config->csv_output)
fprintf(config->output, "%s%.2f%%", config->csv_sep, pct);
else if (pct)
fprintf(config->output, " ( +-%6.2f%% )", pct);
}
static void print_noise(struct perf_stat_config *config,
struct evsel *evsel, double avg)
{
struct perf_stat_evsel *ps;
if (config->run_count == 1)
return;
ps = evsel->stats;
print_noise_pct(config, stddev_stats(&ps->res_stats[0]), avg);
}
static void print_cgroup(struct perf_stat_config *config, struct evsel *evsel)
{
if (nr_cgroups) {
const char *cgrp_name = evsel->cgrp ? evsel->cgrp->name : "";
fprintf(config->output, "%s%s", config->csv_sep, cgrp_name);
}
}
static void aggr_printout(struct perf_stat_config *config,
struct evsel *evsel, int id, int nr)
{
switch (config->aggr_mode) {
case AGGR_CORE:
fprintf(config->output, "S%d-D%d-C%*d%s%*d%s",
cpu_map__id_to_socket(id),
cpu_map__id_to_die(id