summaryrefslogtreecommitdiff
path: root/tools/perf/util/data.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2019-03-08 16:47:38 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2019-03-11 17:56:03 +0300
commit29583c17b5ce0bc17fdd80da939f8199a03d9668 (patch)
tree8153ef506aa1ef72e91405eeace6613ccd4b6baa /tools/perf/util/data.c
parente8be135751f26aa5de63e517d375ecf69e9b20c3 (diff)
downloadlinux-29583c17b5ce0bc17fdd80da939f8199a03d9668.tar.xz
perf data: Make perf_data__size() work over directory
Make perf_data__size() return proper size for directory data, summing up all the individual file sizes. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexey Budankov <alexey.budankov@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/20190308134745.5057-5-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/data.c')
-rw-r--r--tools/perf/util/data.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
index 5d0f26aef77f..b71c441cafbb 100644
--- a/tools/perf/util/data.c
+++ b/tools/perf/util/data.c
@@ -393,3 +393,20 @@ out:
free(new_filepath);
return ret;
}
+
+unsigned long perf_data__size(struct perf_data *data)
+{
+ u64 size = data->file.size;
+ int i;
+
+ if (!data->is_dir)
+ return size;
+
+ for (i = 0; i < data->dir.nr; i++) {
+ struct perf_data_file *file = &data->dir.files[i];
+
+ size += file->size;
+ }
+
+ return size;
+}