Lines Matching full:config

102 static void print_running_std(struct perf_stat_config *config, u64 run, u64 ena)
105 fprintf(config->output, " (%.2f%%)", 100.0 * run / ena);
108 static void print_running_csv(struct perf_stat_config *config, u64 run, u64 ena)
114 fprintf(config->output, "%s%" PRIu64 "%s%.2f",
115 config->csv_sep, run, config->csv_sep, enabled_percent);
118 static void print_running_json(struct perf_stat_config *config, u64 run, u64 ena)
124 fprintf(config->output, "\"event-runtime\" : %" PRIu64 ", \"pcnt-running\" : %.2f, ",
128 static void print_running(struct perf_stat_config *config,
131 if (config->json_output) {
133 print_running_json(config, run, ena);
134 } else if (config->csv_output) {
136 print_running_csv(config, run, ena);
139 print_running_std(config, run, ena);
143 static void print_noise_pct_std(struct perf_stat_config *config,
147 fprintf(config->output, " ( +-%6.2f%% )", pct);
150 static void print_noise_pct_csv(struct perf_stat_config *config,
153 fprintf(config->output, "%s%.2f%%", config->csv_sep, pct);
156 static void print_noise_pct_json(struct perf_stat_config *config,
159 fprintf(config->output, "\"variance\" : %.2f, ", pct);
162 static void print_noise_pct(struct perf_stat_config *config,
167 if (config->json_output) {
169 print_noise_pct_json(config, pct);
170 } else if (config->csv_output) {
172 print_noise_pct_csv(config, pct);
175 print_noise_pct_std(config, pct);
179 static void print_noise(struct perf_stat_config *config,
184 if (config->run_count == 1)
188 print_noise_pct(config, stddev_stats(&ps->res_stats), avg, before_metric);
191 static void print_cgroup_std(struct perf_stat_config *config, const char *cgrp_name)
193 fprintf(config->output, " %-*s", CGROUP_LEN, cgrp_name);
196 static void print_cgroup_csv(struct perf_stat_config *config, const char *cgrp_name)
198 fprintf(config->output, "%s%s", config->csv_sep, cgrp_name);
201 static void print_cgroup_json(struct perf_stat_config *config, const char *cgrp_name)
203 fprintf(config->output, "\"cgroup\" : \"%s\", ", cgrp_name);
206 static void print_cgroup(struct perf_stat_config *config, struct cgroup *cgrp)
208 if (nr_cgroups || config->cgroup_list) {
211 if (config->json_output)
212 print_cgroup_json(config, cgrp_name);
213 else if (config->csv_output)
214 print_cgroup_csv(config, cgrp_name);
216 print_cgroup_std(config, cgrp_name);
220 static void print_aggr_id_std(struct perf_stat_config *config,
223 FILE *output = config->output;
224 int idx = config->aggr_mode;
227 switch (config->aggr_mode) {
248 if (evsel->percore && !config->percore_show_thread) {
273 static void print_aggr_id_csv(struct perf_stat_config *config,
276 FILE *output = config->output;
277 const char *sep = config->csv_sep;
279 switch (config->aggr_mode) {
285 fprintf(config->output, "S%d-D%d-L%d-ID%d%s%d%s",
289 fprintf(config->output, "S%d-D%d-CLS%d%s%d%s",
305 if (evsel->percore && !config->percore_show_thread) {
327 static void print_aggr_id_json(struct perf_stat_config *config,
330 FILE *output = config->output;
332 switch (config->aggr_mode) {
358 if (evsel->percore && !config->percore_show_thread) {
379 static void aggr_printout(struct perf_stat_config *config,
382 if (config->json_output)
383 print_aggr_id_json(config, evsel, id, aggr_nr);
384 else if (config->csv_output)
385 print_aggr_id_csv(config, evsel, id, aggr_nr);
387 print_aggr_id_std(config, evsel, id, aggr_nr);
402 static void new_line_std(struct perf_stat_config *config __maybe_unused,
410 static inline void __new_line_std_csv(struct perf_stat_config *config,
416 aggr_printout(config, os->evsel, os->id, os->aggr_nr);
424 static void do_new_line_std(struct perf_stat_config *config,
427 __new_line_std_csv(config, os);
428 if (config->aggr_mode == AGGR_NONE)
433 static void print_metric_std(struct perf_stat_config *config,
451 do_new_line_std(config, os);
461 static void new_line_csv(struct perf_stat_config *config, void *ctx)
466 __new_line_std_csv(config, os);
468 fputs(config->csv_sep, os->fh);
471 static void print_metric_csv(struct perf_stat_config *config __maybe_unused,
481 fprintf(out, "%s%s", config->csv_sep, config->csv_sep);
489 fprintf(out, "%s%s%s%s", config->csv_sep, vals, config->csv_sep, skip_spaces(unit));
492 static void print_metric_json(struct perf_stat_config *config __maybe_unused,
508 if (!config->metric_only)
512 static void new_line_json(struct perf_stat_config *config, void *ctx)
519 aggr_printout(config, os->evsel, os->id, os->aggr_nr);
522 static void print_metricgroup_header_json(struct perf_stat_config *config,
529 fprintf(config->output, "\"metricgroup\" : \"%s\"}", metricgroup_name);
530 new_line_json(config, ctx);
533 static void print_metricgroup_header_csv(struct perf_stat_config *config,
543 fputs(config->csv_sep, os->fh);
548 fputs(config->csv_sep, os->fh);
549 fprintf(config->output, "%s", metricgroup_name);
550 new_line_csv(config, ctx);
553 static void print_metricgroup_header_std(struct perf_stat_config *config,
565 n = fprintf(config->output, " %*s", EVNAME_LEN, metricgroup_name);
567 fprintf(config->output, "%*s", MGROUP_LEN - n - 1, "");
593 static void print_metric_only(struct perf_stat_config *config,
600 unsigned mlen = config->metric_only_len;
617 static void print_metric_only_csv(struct perf_stat_config *config __maybe_unused,
636 fprintf(out, "%s%s", vals, config->csv_sep);
640 static void print_metric_only_json(struct perf_stat_config *config __maybe_unused,
668 static void new_line_metric(struct perf_stat_config *config __maybe_unused,
673 static void print_metric_header(struct perf_stat_config *config,
683 if (config->iostat_run &&
694 if (config->json_output)
696 else if (config->csv_output)
697 fprintf(os->fh, "%s%s", unit, config->csv_sep);
699 fprintf(os->fh, "%*s ", config->metric_only_len, unit);
702 static void print_counter_value_std(struct perf_stat_config *config,
705 FILE *output = config->output;
710 if (config->big_num)
721 fprintf(output, "%-*s ", config->unit_width, evsel->unit);
726 static void print_counter_value_csv(struct perf_stat_config *config,
729 FILE *output = config->output;
731 const char *sep = config->csv_sep;
746 static void print_counter_value_json(struct perf_stat_config *config,
749 FILE *output = config->output;
763 static void print_counter_value(struct perf_stat_config *config,
766 if (config->json_output)
767 print_counter_value_json(config, evsel, avg, ok);
768 else if (config->csv_output)
769 print_counter_value_csv(config, evsel, avg, ok);
771 print_counter_value_std(config, evsel, avg, ok);
774 static void abs_printout(struct perf_stat_config *config,
778 aggr_printout(config, evsel, id, aggr_nr);
779 print_counter_value(config, evsel, avg, ok);
780 print_cgroup(config, evsel->cgrp);
822 static void printout(struct perf_stat_config *config, struct outstate *os,
832 if (config->csv_output) {
833 pm = config->metric_only ? print_metric_only_csv : print_metric_csv;
834 nl = config->metric_only ? new_line_metric : new_line_csv;
837 } else if (config->json_output) {
838 pm = config->metric_only ? print_metric_only_json : print_metric_json;
839 nl = config->metric_only ? new_line_metric : new_line_json;
842 pm = config->metric_only ? print_metric_only : print_metric_std;
843 nl = config->metric_only ? new_line_metric : new_line_std;
848 if (config->metric_only) {
849 pm(config, os, METRIC_THRESHOLD_UNKNOWN, "", "", 0);
857 config->print_free_counters_hint = 1;
859 config->print_mixed_hw_group_error = 1;
870 if (!config->metric_only && !counter->default_metricgroup) {
871 abs_printout(config, os->id, os->aggr_nr, counter, uval, ok);
873 print_noise(config, counter, noise, /*before_metric=*/true);
874 print_running(config, run, ena, /*before_metric=*/true);
878 if (!config->metric_only && counter->default_metricgroup) {
881 aggr_printout(config, os->evsel, os->id, os->aggr_nr);
888 if (config->json_output)
889 new_line_json(config, (void *)os);
891 __new_line_std_csv(config, os);
894 print_noise(config, counter, noise, /*before_metric=*/true);
895 print_running(config, run, ena, /*before_metric=*/true);
896 from = perf_stat__print_shadow_stats_metricgroup(config, counter, aggr_idx,
898 &config->metric_events);
901 perf_stat__print_shadow_stats(config, counter, uval, aggr_idx,
902 &out, &config->metric_events);
904 pm(config, os, METRIC_THRESHOLD_UNKNOWN, /*format=*/NULL, /*unit=*/"", /*val=*/0);
907 if (!config->metric_only) {
908 print_noise(config, counter, noise, /*before_metric=*/false);
909 print_running(config, run, ena, /*before_metric=*/false);
916 char *new_name, *config;
926 /* The evsel has a "name=" config term or is from libpfm. */
945 config = strchr(name, '/');
946 if (config) {
947 int len = config - name;
949 if (config[1] == '/') {
951 ret = asprintf(&new_name, "%s/%.*s/%s", pmu_name, len, name, config + 2);
954 ret = asprintf(&new_name, "%s/%.*s,%s", pmu_name, len, name, config + 1);
957 config = strchr(name, ':');
958 if (config) {
960 int len = config - name;
962 ret = asprintf(&new_name, "%s/%.*s/%s", pmu_name, len, name, config + 1);
977 static bool hybrid_uniquify(struct evsel *evsel, struct perf_stat_config *config)
979 return evsel__is_hybrid(evsel) && !config->hybrid_merge;
982 static void uniquify_counter(struct perf_stat_config *config, struct evsel *counter)
984 if (config->aggr_mode == AGGR_NONE || hybrid_uniquify(counter, config))
990 * @config: The perf stat configuration (including aggregation mode).
1004 static bool should_skip_zero_counter(struct perf_stat_config *config,
1022 if (config->aggr_mode == AGGR_THREAD && config->system_wide)
1031 config->aggr_get_id(config, (struct perf_cpu){ .cpu = 0 });
1044 struct aggr_cpu_id own_id = config->aggr_get_id(config, cpu);
1052 static void print_counter_aggrdata(struct perf_stat_config *config,
1056 FILE *output = config->output;
1061 struct aggr_cpu_id id = config->aggr_map->map[aggr_idx];
1063 bool metric_only = config->metric_only;
1073 uniquify_counter(config, counter);
1079 if (perf_stat__skip_metric_event(counter, &config->metric_events, ena, run))
1082 if (val == 0 && should_skip_zero_counter(config, counter, &id))
1086 if (config->json_output)
1090 else if (config->summary && config->csv_output &&
1091 !config->no_csv_summary && !config->interval)
1092 fprintf(output, "%s%s", "summary", config->csv_sep);
1097 printout(config, os, uval, run, ena, avg, aggr_idx);
1103 static void print_metric_begin(struct perf_stat_config *config,
1112 if (!config->metric_only)
1115 if (config->json_output)
1116 fputc('{', config->output);
1118 fprintf(config->output, "%s", os->prefix);
1121 id = config->aggr_map->map[aggr_idx];
1123 aggr_printout(config, evsel, id, aggr->nr);
1125 print_cgroup(config, os->cgrp ? : evsel->cgrp);
1128 static void print_metric_end(struct perf_stat_config *config, struct outstate *os)
1130 FILE *output = config->output;
1132 if (!config->metric_only)
1135 if (config->json_output) {
1143 static void print_aggr(struct perf_stat_config *config,
1150 if (!config->aggr_map || !config->aggr_get_id)
1157 cpu_aggr_map__for_each_idx(aggr_idx, config->aggr_map) {
1158 print_metric_begin(config, evlist, os, aggr_idx);
1161 print_counter_aggrdata(config, counter, aggr_idx, os);
1163 print_metric_end(config, os);
1167 static void print_aggr_cgroup(struct perf_stat_config *config,
1174 if (!config->aggr_map || !config->aggr_get_id)
1183 cpu_aggr_map__for_each_idx(aggr_idx, config->aggr_map) {
1184 print_metric_begin(config, evlist, os, aggr_idx);
1190 print_counter_aggrdata(config, counter, aggr_idx, os);
1192 print_metric_end(config, os);
1197 static void print_counter(struct perf_stat_config *config,
1202 /* AGGR_THREAD doesn't have config->aggr_get_id */
1203 if (!config->aggr_map)
1206 cpu_aggr_map__for_each_idx(aggr_idx, config->aggr_map) {
1207 print_counter_aggrdata(config, counter, aggr_idx, os);
1211 static void print_no_aggr_metric(struct perf_stat_config *config,
1231 cpu_aggr_map__for_each_idx(aggr_idx, config->aggr_map) {
1232 if (config->aggr_map->map[aggr_idx].cpu.cpu == cpu.cpu)
1239 print_metric_begin(config, evlist, os, aggr_idx);
1247 printout(config, os, uval, run, ena, 1.0, aggr_idx);
1250 print_metric_end(config, os);
1254 static void print_metric_headers_std(struct perf_stat_config *config,
1257 fputc(' ', config->output);
1260 int len = aggr_header_lens[config->aggr_mode];
1262 if (nr_cgroups || config->cgroup_list)
1265 fprintf(config->output, "%*s", len, "");
1269 static void print_metric_headers_csv(struct perf_stat_config *config,
1274 if (config->interval)
1275 fprintf(config->output, "time%s", config->csv_sep);
1276 if (config->iostat_run)
1279 p = aggr_header_csv[config->aggr_mode];
1282 fputs(config->csv_sep, config->output);
1284 fputc(*p, config->output);
1289 static void print_metric_headers_json(struct perf_stat_config *config __maybe_unused,
1294 static void print_metric_headers(struct perf_stat_config *config,
1299 .fh = config->output
1308 if (config->json_output)
1309 print_metric_headers_json(config, no_indent);
1310 else if (config->csv_output)
1311 print_metric_headers_csv(config, no_indent);
1313 print_metric_headers_std(config, no_indent);
1315 if (config->iostat_run)
1316 iostat_print_header_prefix(config);
1318 if (config->cgroup_list)
1323 if (!config->iostat_run &&
1324 config->aggr_mode != AGGR_NONE && counter->metric_leader != counter)
1329 perf_stat__print_shadow_stats(config, counter, 0,
1332 &config->metric_events);
1335 if (!config->json_output)
1336 fputc('\n', config->output);
1339 static void prepare_interval(struct perf_stat_config *config,
1342 if (config->iostat_run)
1345 if (config->json_output)
1348 else if (config->csv_output)
1350 (unsigned long) ts->tv_sec, ts->tv_nsec, config->csv_sep);
1356 static void print_header_interval_std(struct perf_stat_config *config,
1362 FILE *output = config->output;
1364 switch (config->aggr_mode) {
1373 aggr_header_lens[config->aggr_mode],
1374 aggr_header_std[config->aggr_mode]);
1379 aggr_header_lens[config->aggr_mode],
1380 aggr_header_std[config->aggr_mode]);
1389 if (!config->iostat_run)
1397 if (config->metric_only)
1398 print_metric_headers(config, evlist, true);
1401 COUNTS_LEN, "counts", config->unit_width, "unit");
1404 static void print_header_std(struct perf_stat_config *config,
1408 FILE *output = config->output;
1429 if (config->run_count > 1)
1430 fprintf(output, " (%d runs)", config->run_count);
1433 if (config->metric_only)
1434 print_metric_headers(config, evlist, false);
1437 static void print_header_csv(struct perf_stat_config *config,
1443 if (config->metric_only)
1444 print_metric_headers(config, evlist, true);
1446 static void print_header_json(struct perf_stat_config *config,
1452 if (config->metric_only)
1453 print_metric_headers(config, evlist, true);
1456 static void print_header(struct perf_stat_config *config,
1465 if (config->interval_clear)
1468 if (num_print_iv == 0 || config->interval_clear) {
1469 if (config->json_output)
1470 print_header_json(config, _target, evlist, argc, argv);
1471 else if (config->csv_output)
1472 print_header_csv(config, _target, evlist, argc, argv);
1473 else if (config->interval)
1474 print_header_interval_std(config, _target, evlist, argc, argv);
1476 print_header_std(config, _target, evlist, argc, argv);
1491 static void print_table(struct perf_stat_config *config,
1503 for (idx = 0; idx < config->run_count; idx++) {
1504 double run = (double) config->walltime_run[idx] / NSEC_PER_SEC;
1524 static void print_footer(struct perf_stat_config *config)
1526 double avg = avg_stats(config->walltime_nsecs_stats) / NSEC_PER_SEC;
1527 FILE *output = config->output;
1529 if (config->interval || config->csv_output || config->json_output)
1532 if (!config->null_run)
1535 if (config->run_count == 1) {
1538 if (config->ru_display) {
1539 double ru_utime = timeval2double(&config->ru_data.ru_utime);
1540 double ru_stime = timeval2double(&config->ru_data.ru_stime);
1547 double sd = stddev_stats(config->walltime_nsecs_stats) / NSEC_PER_SEC;
1554 if (config->walltime_run_table)
1555 print_table(config, output, precision, avg);
1560 print_noise_pct(config, sd, avg, /*before_metric=*/false);
1564 if (config->print_free_counters_hint && sysctl__nmi_watchdog_enabled())
1571 if (config->print_mixed_hw_group_error)
1577 static void print_percore(struct perf_stat_config *config,
1580 bool metric_only = config->metric_only;
1581 FILE *output = config->output;
1585 if (!config->aggr_map || !config->aggr_get_id)
1588 if (config->percore_show_thread)
1589 return print_counter(config, counter, os);
1595 core_map = cpu_aggr_map__empty_new(config->aggr_map->nr);
1601 cpu_aggr_map__for_each_idx(aggr_idx, config->aggr_map) {
1602 struct perf_cpu curr_cpu = config->aggr_map->map[aggr_idx].cpu;
1615 print_counter_aggrdata(config, counter, aggr_idx, os);
1625 static void print_cgroup_counter(struct perf_stat_config *config, struct evlist *evlist,
1633 print_metric_end(config, os);
1636 print_metric_begin(config, evlist, os, /*aggr_idx=*/0);
1639 print_counter(config, counter, os);
1642 print_metric_end(config, os);
1670 void evlist__print_counters(struct evlist *evlist, struct perf_stat_config *config,
1674 bool metric_only = config->metric_only;
1675 int interval = config->interval;
1679 .fh = config->output,
1685 if (config->iostat_run)
1690 prepare_interval(config, buf, sizeof(buf), ts);
1693 print_header(config, _target, evlist, argc, argv);
1695 switch (config->aggr_mode) {
1702 if (config->cgroup_list)
1703 print_aggr_cgroup(config, evlist, &os);
1705 print_aggr(config, evlist, &os);
1709 if (config->iostat_run) {
1710 iostat_print_counters(evlist, config, ts, buf,
1712 } else if (config->cgroup_list) {
1713 print_cgroup_counter(config, evlist, &os);
1715 print_metric_begin(config, evlist, &os, /*aggr_idx=*/0);
1717 print_counter(config, counter, &os);
1719 print_metric_end(config, &os);
1724 print_no_aggr_metric(config, evlist, &os);
1728 print_percore(config, counter, &os);
1730 print_counter(config, counter, &os);
1740 print_footer(config);
1742 fflush(config->output);