[ OEMCrypto Profiler ] Removed Call Table am: 4ad500d878
am: 9ae9de59d4
Change-Id: Ic34ac456ba79b8fcdf215eb7174bfc40181d1974
This commit is contained in:
@@ -39,7 +39,6 @@ LOCAL_SRC_FILES := \
|
||||
$(PROFILER_SRC_DIR)/entry_writer.cpp \
|
||||
$(PROFILER_SRC_DIR)/profiled_scope.cpp \
|
||||
$(PROFILER_SRC_DIR)/profiler.cpp \
|
||||
$(PROFILER_SRC_DIR)/call_table.cpp \
|
||||
$(PROFILER_SRC_DIR)/call_history.cpp
|
||||
|
||||
LOCAL_MODULE := libcdm
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
#ifndef WVCDM_PROFILER_CALL_TABLE_H_
|
||||
#define WVCDM_PROFILER_CALL_TABLE_H_
|
||||
|
||||
#include <map>
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
namespace wvcdm {
|
||||
namespace oemprofiler {
|
||||
|
||||
class CallTable {
|
||||
public:
|
||||
class Row {
|
||||
public:
|
||||
Row();
|
||||
void Add(uint64_t sample);
|
||||
|
||||
uint64_t GetSampleSize() const;
|
||||
|
||||
uint64_t GetMin() const;
|
||||
uint64_t GetMax() const;
|
||||
|
||||
double GetMean() const;
|
||||
double GetVariance() const;
|
||||
|
||||
private:
|
||||
uint64_t min_;
|
||||
uint64_t max_;
|
||||
uint64_t sample_size_;
|
||||
double mean_;
|
||||
double variance_m_;
|
||||
double variance_s_;
|
||||
|
||||
};
|
||||
|
||||
const Row* LookUp(uint64_t row_id) const;
|
||||
|
||||
void Write(uint64_t row_id, uint64_t sample);
|
||||
|
||||
void Read(std::vector<uint8_t>& output) const;
|
||||
|
||||
private:
|
||||
std::map<uint64_t, Row> map_;
|
||||
};
|
||||
|
||||
} // namespace oemprofiler
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif
|
||||
@@ -3,7 +3,6 @@
|
||||
#ifndef WVCDM_PROFILER_H_
|
||||
#define WVCDM_PROFILER_H_
|
||||
|
||||
#include "call_table.h"
|
||||
#include "call_history.h"
|
||||
|
||||
namespace wvcdm {
|
||||
@@ -11,11 +10,9 @@ namespace oemprofiler {
|
||||
|
||||
class Profiler {
|
||||
public:
|
||||
static CallTable& GetTable();
|
||||
static CallHistory& GetHistory();
|
||||
|
||||
private:
|
||||
static CallTable global_table_;
|
||||
static CallHistory global_history_;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
#include "call_table.h"
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include "entry_writer.h"
|
||||
|
||||
namespace wvcdm {
|
||||
namespace oemprofiler {
|
||||
|
||||
namespace {
|
||||
const uint8_t kOutputVersionNumber = 0x00;
|
||||
}
|
||||
|
||||
CallTable::Row::Row() :
|
||||
min_(std::numeric_limits<uint64_t>::max()),
|
||||
max_(0),
|
||||
sample_size_(0),
|
||||
mean_(0),
|
||||
variance_m_(0),
|
||||
variance_s_(0) {
|
||||
|
||||
}
|
||||
|
||||
void CallTable::Row::Add(uint64_t value) {
|
||||
min_ = std::min(min_, value);
|
||||
max_ = std::max(max_, value);
|
||||
|
||||
mean_ = ((mean_ * sample_size_) + value) / (sample_size_ + 1.0);
|
||||
sample_size_ += 1;
|
||||
|
||||
// Welford's method for standard deviation and variance
|
||||
const double old_m = variance_m_;
|
||||
const double old_s = variance_s_;
|
||||
variance_m_ = old_m + (value - old_m) / sample_size_;
|
||||
variance_s_ = old_s + (value - variance_m_) * (value -old_m);
|
||||
}
|
||||
|
||||
uint64_t CallTable::Row::GetSampleSize() const {
|
||||
return sample_size_;
|
||||
}
|
||||
|
||||
uint64_t CallTable::Row::GetMin() const {
|
||||
return min_;
|
||||
}
|
||||
|
||||
uint64_t CallTable::Row::GetMax() const {
|
||||
return max_;
|
||||
}
|
||||
|
||||
double CallTable::Row::GetMean() const {
|
||||
return mean_;
|
||||
}
|
||||
|
||||
double CallTable::Row::GetVariance() const {
|
||||
return sample_size_ > 1 ? variance_s_ / (sample_size_ - 1) : 0;
|
||||
}
|
||||
|
||||
const CallTable::Row* CallTable::LookUp(uint64_t row_id) const {
|
||||
return map_.count(row_id) == 0 ? NULL : &map_.find(row_id)->second;
|
||||
}
|
||||
|
||||
void CallTable::Write(uint64_t row_id, uint64_t sample) {
|
||||
if (map_.count(row_id) == 0) {
|
||||
map_.insert(std::pair<uint64_t, Row>(row_id, Row()));
|
||||
}
|
||||
|
||||
map_[row_id].Add(sample);
|
||||
}
|
||||
|
||||
void CallTable::Read(std::vector<uint8_t>& output) const {
|
||||
output.push_back(kOutputVersionNumber);
|
||||
|
||||
for (std::map<uint64_t, Row>::const_iterator it = map_.begin();
|
||||
it != map_.end(); ++it) {
|
||||
|
||||
const uint64_t values_to_write[] = {
|
||||
it->first,
|
||||
it->second.GetSampleSize(),
|
||||
it->second.GetMin(),
|
||||
it->second.GetMax(),
|
||||
static_cast<uint64_t>(it->second.GetMean()),
|
||||
// get the decimal places to the one-hundredths
|
||||
static_cast<uint64_t>(it->second.GetMean() * 100) % 100,
|
||||
static_cast<uint64_t>(it->second.GetVariance()),
|
||||
// get the decimal places to the one-hundredths
|
||||
static_cast<uint64_t>(it->second.GetVariance() * 100) % 100
|
||||
};
|
||||
|
||||
const size_t kValuesToWriteSize = 8;
|
||||
|
||||
for (size_t i = 0; i < kValuesToWriteSize; i++) {
|
||||
EntryWriter writer;
|
||||
writer.WriteVLV(values_to_write[i]);
|
||||
|
||||
for (size_t w_i = 0; w_i < writer.GetSize(); w_i++) {
|
||||
output.push_back(writer.GetData()[w_i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace oemprofiler
|
||||
} // namespace wvcdm
|
||||
@@ -21,7 +21,6 @@ ProfiledScope::~ProfiledScope() {
|
||||
}
|
||||
|
||||
void ProfiledScope::Submit(uint64_t end_time) const {
|
||||
Profiler::GetTable().Write(fid_, end_time - start_time_);
|
||||
|
||||
Profiler::GetHistory().Write(
|
||||
fid_,
|
||||
|
||||
@@ -5,13 +5,8 @@
|
||||
namespace wvcdm {
|
||||
namespace oemprofiler {
|
||||
|
||||
CallTable Profiler::global_table_;
|
||||
CallHistory Profiler::global_history_;
|
||||
|
||||
CallTable& Profiler::GetTable() {
|
||||
return global_table_;
|
||||
}
|
||||
|
||||
CallHistory& Profiler::GetHistory() {
|
||||
return global_history_;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ namespace {
|
||||
|
||||
// profiler proterties constants
|
||||
static const android::String8 kProfilerHistoryTag("oemProfilerHistory");
|
||||
static const android::String8 kProfilerStatsTag("oemProfilerStats");
|
||||
}
|
||||
|
||||
namespace wvdrm {
|
||||
@@ -512,28 +511,11 @@ bool WVDrmPlugin::tryGettingOEMProfilingHistory(const String8& name,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WVDrmPlugin::tryGettingOEMProfilingStats(
|
||||
const String8& name,
|
||||
Vector<uint8_t>& value) const {
|
||||
|
||||
if (name == kProfilerStatsTag) {
|
||||
std::vector<uint8_t> tempValue;
|
||||
oemprofiler::Profiler::GetTable().Read(tempValue);
|
||||
value.appendArray(tempValue.data(), tempValue.size());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
status_t WVDrmPlugin::getPropertyByteArray(const String8& name,
|
||||
Vector<uint8_t>& value) const {
|
||||
|
||||
if (tryGettingOEMProfilingHistory(name, value)) {
|
||||
return android::OK;
|
||||
} else if (tryGettingOEMProfilingStats(name, value)) {
|
||||
return android::OK;
|
||||
} else if (name == "deviceUniqueId") {
|
||||
return queryProperty(QUERY_KEY_DEVICE_ID, value);
|
||||
} else if (name == "provisioningUniqueId") {
|
||||
|
||||
Reference in New Issue
Block a user