diff options
author | Yabin Cui <yabinc@google.com> | 2016-07-26 15:03:27 -0700 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2016-07-27 14:37:13 -0700 |
commit | 3e4c5950f3aafb0bf66544468d98ee3ec26b705c (patch) | |
tree | 0b7dca91eb9ffd0e729dd01f68f34b67d500dd13 /simpleperf/utils.cpp | |
parent | 5b46f5747cdc481f8d1f51b3f8664335a2fdbcb4 (diff) | |
download | extras-3e4c5950f3aafb0bf66544468d98ee3ec26b705c.tar.gz |
simpleperf: use libevent in stat command.
Wrap libevent in IOEventLoop, use IOEventLoop in stat command.
Add corresponding tests.
Bug: http://b/30405638
Change-Id: I78b79e0eff1365ab46dde29c2a24a2def586af79
Test: run simpleperf_unit_test.
Diffstat (limited to 'simpleperf/utils.cpp')
-rw-r--r-- | simpleperf/utils.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/simpleperf/utils.cpp b/simpleperf/utils.cpp index 2df15e6b..b71f98b3 100644 --- a/simpleperf/utils.cpp +++ b/simpleperf/utils.cpp @@ -271,7 +271,7 @@ bool IsRoot() { } bool ProcessKernelSymbols(std::string& symbol_data, - std::function<bool(const KernelSymbol&)> callback) { + const std::function<bool(const KernelSymbol&)>& callback) { char* p = &symbol_data[0]; char* data_end = p + symbol_data.size(); while (p < data_end) { @@ -333,3 +333,10 @@ uint64_t ConvertBytesToValue(const char* bytes, uint32_t size) { LOG(FATAL) << "unexpected size " << size << " in ConvertBytesToValue"; return 0; } + +timeval SecondToTimeval(double time_in_sec) { + timeval tv; + tv.tv_sec = static_cast<time_t>(time_in_sec); + tv.tv_usec = static_cast<int>((time_in_sec - tv.tv_sec) * 1000000); + return tv; +} |