aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-stat.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-stat.c')
-rw-r--r--tools/perf/builtin-stat.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 7e17bf9f700a..60cdd383af81 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -61,6 +61,7 @@
61#include "util/tool.h" 61#include "util/tool.h"
62#include "util/string2.h" 62#include "util/string2.h"
63#include "util/metricgroup.h" 63#include "util/metricgroup.h"
64#include "util/synthetic-events.h"
64#include "util/target.h" 65#include "util/target.h"
65#include "util/time-utils.h" 66#include "util/time-utils.h"
66#include "util/top.h" 67#include "util/top.h"
@@ -540,8 +541,8 @@ try_again:
540 if (err < 0) 541 if (err < 0)
541 return err; 542 return err;
542 543
543 err = perf_stat_synthesize_config(&stat_config, NULL, evsel_list, 544 err = perf_event__synthesize_stat_events(&stat_config, NULL, evsel_list,
544 process_synthesized_event, is_pipe); 545 process_synthesized_event, is_pipe);
545 if (err < 0) 546 if (err < 0)
546 return err; 547 return err;
547 } 548 }
@@ -822,18 +823,6 @@ static int perf_stat__get_core(struct perf_stat_config *config __maybe_unused,
822 return cpu_map__get_core(map, cpu, NULL); 823 return cpu_map__get_core(map, cpu, NULL);
823} 824}
824 825
825static int cpu_map__get_max(struct perf_cpu_map *map)
826{
827 int i, max = -1;
828
829 for (i = 0; i < map->nr; i++) {
830 if (map->map[i] > max)
831 max = map->map[i];
832 }
833
834 return max;
835}
836
837static int perf_stat__get_aggr(struct perf_stat_config *config, 826static int perf_stat__get_aggr(struct perf_stat_config *config,
838 aggr_get_id_t get_id, struct perf_cpu_map *map, int idx) 827 aggr_get_id_t get_id, struct perf_cpu_map *map, int idx)
839{ 828{
@@ -928,7 +917,7 @@ static int perf_stat_init_aggr_mode(void)
928 * taking the highest cpu number to be the size of 917 * taking the highest cpu number to be the size of
929 * the aggregation translate cpumap. 918 * the aggregation translate cpumap.
930 */ 919 */
931 nr = cpu_map__get_max(evsel_list->core.cpus); 920 nr = perf_cpu_map__max(evsel_list->core.cpus);
932 stat_config.cpus_aggr_map = perf_cpu_map__empty_new(nr + 1); 921 stat_config.cpus_aggr_map = perf_cpu_map__empty_new(nr + 1);
933 return stat_config.cpus_aggr_map ? 0 : -ENOMEM; 922 return stat_config.cpus_aggr_map ? 0 : -ENOMEM;
934} 923}
@@ -1963,8 +1952,11 @@ int cmd_stat(int argc, const char **argv)
1963 fprintf(output, "[ perf stat: executing run #%d ... ]\n", 1952 fprintf(output, "[ perf stat: executing run #%d ... ]\n",
1964 run_idx + 1); 1953 run_idx + 1);
1965 1954
1955 if (run_idx != 0)
1956 perf_evlist__reset_prev_raw_counts(evsel_list);
1957
1966 status = run_perf_stat(argc, argv, run_idx); 1958 status = run_perf_stat(argc, argv, run_idx);
1967 if (forever && status != -1) { 1959 if (forever && status != -1 && !interval) {
1968 print_counters(NULL, argc, argv); 1960 print_counters(NULL, argc, argv);
1969 perf_stat__reset_stats(); 1961 perf_stat__reset_stats();
1970 } 1962 }