This is a merge of go/wvgerrit/22627 The call table was meant to be a long-term way to track the performance of all OEMCrypto function calls. This feature does not get used. Apps that call into the profiler can generate this from the history. This change was designed to go into Android O (go/wvgerrit/22503) but since the Call Table is causing problems on specific chip sets its being removed in NYC MR2. Bug: 33550032 Bug: 33459261 Change-Id: I2af417a32452e7d0d0a1ada8794efd849c497dc8
44 lines
844 B
C++
44 lines
844 B
C++
// Copyright 2016 Google Inc. All Rights Reserved
|
|
|
|
#include "profiled_scope.h"
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include "profiler.h"
|
|
|
|
namespace wvcdm {
|
|
namespace oemprofiler {
|
|
|
|
ProfiledScope::ProfiledScope(OEM_FUNCTION fid) :
|
|
meta_data_(),
|
|
fid_(fid),
|
|
start_time_(GetNowUS()) {
|
|
|
|
}
|
|
|
|
ProfiledScope::~ProfiledScope() {
|
|
Submit(GetNowUS());
|
|
}
|
|
|
|
void ProfiledScope::Submit(uint64_t end_time) const {
|
|
|
|
Profiler::GetHistory().Write(
|
|
fid_,
|
|
start_time_,
|
|
end_time,
|
|
meta_data_.GetData(),
|
|
meta_data_.GetSize());
|
|
}
|
|
|
|
uint64_t ProfiledScope::GetNowUS() const {
|
|
struct timeval tv;
|
|
gettimeofday(&tv, NULL);
|
|
|
|
const uint64_t kSecondsToUSeconds = 1000000;
|
|
return static_cast<uint64_t>(tv.tv_sec) * kSecondsToUSeconds +
|
|
static_cast<uint64_t>(tv.tv_usec);
|
|
}
|
|
|
|
} // namespace oemprofiler
|
|
} // namespace wvcdm
|