diff options
Diffstat (limited to 'libperfmgr/RequestGroup.cc')
-rw-r--r-- | libperfmgr/RequestGroup.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libperfmgr/RequestGroup.cc b/libperfmgr/RequestGroup.cc index 857d17a4..4fedd33a 100644 --- a/libperfmgr/RequestGroup.cc +++ b/libperfmgr/RequestGroup.cc @@ -18,6 +18,11 @@ #include "perfmgr/RequestGroup.h" +#include <android-base/file.h> +#include <android-base/logging.h> + +#include <sstream> + namespace android { namespace perfmgr { @@ -60,5 +65,20 @@ bool RequestGroup::GetExpireTime(std::chrono::milliseconds* expire_time) { return active; } +void RequestGroup::DumpToFd(int fd, const std::string& prefix) const { + std::ostringstream dump_buf; + ReqTime now = std::chrono::steady_clock::now(); + for (auto it = request_map_.begin(); it != request_map_.end(); it++) { + auto remaining_duration = + std::chrono::duration_cast<std::chrono::milliseconds>(it->second - + now); + dump_buf << prefix << it->first << "\t" << remaining_duration.count() + << "\t" << request_value_ << "\n"; + } + if (!android::base::WriteStringToFd(dump_buf.str(), fd)) { + LOG(ERROR) << "Failed to dump fd: " << fd; + } +} + } // namespace perfmgr } // namespace android |