Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1322097
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 10/16] perf tools: Move timestamp creation to util |
| Date | 2016-01-29 22:30 +0100 |
| Message-ID | <qWoMb-IK-29@gated-at.bofh.it> (permalink) |
| References | <qWoCu-F7-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
See http://www.infradead.org/rpr.html
From: Wang Nan <wangnan0@huawei.com>
Timestamp generation becomes a public available helper. Which will
be used by 'perf record', help it output to split output file based
on time.
For example:
perf.data.2015122620363710
perf.data.2015122620364092
perf.data.2015122620365423
...
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1453715801-7732-27-git-send-email-wangnan0@huawei.com
Signed-off-by: He Kuang <hekuang@huawei.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-buildid-cache.c | 14 +-------------
tools/perf/util/util.c | 17 +++++++++++++++++
tools/perf/util/util.h | 1 +
3 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c
index d93bff7fc0e4..632efc6b79a0 100644
--- a/tools/perf/builtin-buildid-cache.c
+++ b/tools/perf/builtin-buildid-cache.c
@@ -38,19 +38,7 @@ static int build_id_cache__kcore_buildid(const char *proc_dir, char *sbuildid)
static int build_id_cache__kcore_dir(char *dir, size_t sz)
{
- struct timeval tv;
- struct tm tm;
- char dt[32];
-
- if (gettimeofday(&tv, NULL) || !localtime_r(&tv.tv_sec, &tm))
- return -1;
-
- if (!strftime(dt, sizeof(dt), "%Y%m%d%H%M%S", &tm))
- return -1;
-
- scnprintf(dir, sz, "%s%02u", dt, (unsigned)tv.tv_usec / 10000);
-
- return 0;
+ return fetch_current_timestamp(dir, sz);
}
static bool same_kallsyms_reloc(const char *from_dir, char *to_dir)
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 7a2da7ef556e..b9e2843cfbe7 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -701,3 +701,20 @@ bool is_regular_file(const char *file)
return S_ISREG(st.st_mode);
}
+
+int fetch_current_timestamp(char *buf, size_t sz)
+{
+ struct timeval tv;
+ struct tm tm;
+ char dt[32];
+
+ if (gettimeofday(&tv, NULL) || !localtime_r(&tv.tv_sec, &tm))
+ return -1;
+
+ if (!strftime(dt, sizeof(dt), "%Y%m%d%H%M%S", &tm))
+ return -1;
+
+ scnprintf(buf, sz, "%s%02u", dt, (unsigned)tv.tv_usec / 10000);
+
+ return 0;
+}
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 61650f05e5c1..a8615816a00d 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -344,5 +344,6 @@ int fetch_kernel_version(unsigned int *puint,
const char *perf_tip(const char *dirpath);
bool is_regular_file(const char *file);
+int fetch_current_timestamp(char *buf, size_t sz);
#endif /* GIT_COMPAT_UTIL_H */
--
2.5.0
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[GIT PULL 00/16] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-29 22:20 +0100
[PATCH 16/16] perf build: Align the names of the build tests: Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-29 22:20 +0100
[PATCH 06/16] perf auxtrace: Add perf_evlist pointer to *info_priv_size() Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-29 22:20 +0100
[PATCH 14/16] perf kvm/powerpc: Port perf kvm stat to powerpc Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-29 22:30 +0100
[PATCH 08/16] perf test: Check environment before start real BPF test Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-29 22:30 +0100
[PATCH 13/16] perf kvm/{x86,s390}: Remove const from kvm_events_tp Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-29 22:30 +0100
[PATCH 02/16] perf build: Fix feature-dump checks, we need to test all features Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-29 22:30 +0100
[PATCH 10/16] perf tools: Move timestamp creation to util Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-29 22:30 +0100
[PATCH 01/16] tools build: Check basic headers for test-compile feature checker Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-29 22:30 +0100
[PATCH 07/16] perf buildid: Fix cpumode of buildid event Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-29 22:30 +0100
[PATCH 03/16] perf build: Remove all condition feature check {C,LD}FLAGS Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-29 22:30 +0100
[PATCH 05/16] perf tools: Speed up build-tests by reducing the number of builds tested Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-01-29 22:30 +0100
Re: [GIT PULL 00/16] perf/core improvements and fixes Ingo Molnar <mingo@kernel.org> - 2016-02-03 11:10 +0100
csiph-web