OEMCrypto Profiler
This CL is a merge from the widevine repo of: http://go/wvgerrit/16491 Circular Buffer http://go/wvgerrit/16512 Circular Buffer Tests http://go/wvgerrit/16493 Entry Writer http://go/wvgerrit/16495 Profiled Scope http://go/wvgerrit/16500 Stats Collection http://go/wvgerrit/16543 Disallow Stats Copy or Assign http://go/wvgerrit/16514 Moving OEM Function Enum http://go/wvgerrit/16501 Defining Session Interface http://go/wvgerrit/16502 Session Definitions http://go/wvgerrit/16573 Remove code to num bytes table http://go/wvgerrit/16556 Connecting Profiler to Profiled Scope http://go/wvgerrit/16557 Android Reading Profiler History http://go/wvgerrit/16574 Adding Get Stats Method http://go/wvgerrit/16606 Seperating Session Parsing http://go/wvgerrit/16607 Adding get stats method to DRMPlugin http://go/wvgerrit/16608 Fixing Linux Build Failure http://go/wvgerrit/16612 Stop Clearing History http://go/wvgerrit/16613 Accessing profiler information using session id http://go/wvgerrit/16614 Making All Session Subsets of Global Session BUG: 25123303 BUG: 26027857 Change-Id: Ie2422e644aa631871852ea0e461695aeb7060f88
This commit is contained in:
66
libwvdrmengine/cdm/profiler/src/profiled_scope.cpp
Normal file
66
libwvdrmengine/cdm/profiler/src/profiled_scope.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
// Copyright 2016 Google Inc. All Rights Reserved
|
||||
|
||||
#include "profiled_scope.h"
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "profiler_session.h"
|
||||
|
||||
namespace wvcdm {
|
||||
namespace oemprofiler {
|
||||
|
||||
ProfiledScope::ProfiledScope(OEM_FUNCTION fid) :
|
||||
meta_data_(),
|
||||
sid_(kGlobalSID),
|
||||
fid_(fid),
|
||||
start_time_(GetNowUS()) {
|
||||
|
||||
}
|
||||
|
||||
// Only allow a user provided sid to be a positive integer
|
||||
// to prevent a user provided sid from conflicting with the
|
||||
// global sid
|
||||
ProfiledScope::ProfiledScope(uint32_t sid, OEM_FUNCTION fid) :
|
||||
meta_data_(),
|
||||
sid_(static_cast<int64_t>(sid)),
|
||||
fid_(fid),
|
||||
start_time_(GetNowUS()) {
|
||||
|
||||
}
|
||||
|
||||
ProfiledScope::~ProfiledScope() {
|
||||
const uint64_t end_time = GetNowUS();
|
||||
|
||||
if (sid_ != kGlobalSID) {
|
||||
Submit(sid_, end_time);
|
||||
}
|
||||
|
||||
// Always save a copy to the global session so that all other sessions
|
||||
// are subsets of the global session
|
||||
Submit(kGlobalSID, end_time);
|
||||
}
|
||||
|
||||
void ProfiledScope::Submit(int64_t sid, uint64_t end_time) const {
|
||||
ProfilerSession* const session = ProfilerSession::Find(sid);
|
||||
|
||||
if (session != NULL) {
|
||||
session->Submit(
|
||||
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
|
||||
Reference in New Issue
Block a user