OEMCrypto Profiler - Merge of Widevine Updates
This change is a merge of the following changes: 1. Remove MultipleSessions (go/wvgerrit/16763) 2. Increase Memory Budget (go/wvgerrit/16764) 3. Fixing Possible Integer Overflow (go/wvgerrit/16765) 4. Creating Call Table (go/wvgerrit/16766) 5. Creating Call History (go/wvgerrit/16767) 6. Connecting Profiled Scope (go/wvgerrit/16768) 7. Adding Call Table Version Number (go/wvgerrit/16780) 8. Add Version Number to Call History (go/wvgerrit/16781) bug: 27157796 Change-Id: Ia3f088a1714f3f5b426fee6141daa4ea8d832cf4
This commit is contained in:
49
libwvdrmengine/cdm/profiler/include/call_history.h
Normal file
49
libwvdrmengine/cdm/profiler/include/call_history.h
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright 2016 Google Inc. All Rights Reserved.
|
||||
|
||||
#ifndef WVCDM_CALL_HISTORY_H_
|
||||
#define WVCDM_CALL_HISTORY_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
#include "circular_buffer.h"
|
||||
#include "oem_functions.h"
|
||||
|
||||
namespace wvcdm {
|
||||
namespace oemprofiler {
|
||||
|
||||
class CallHistory {
|
||||
|
||||
public:
|
||||
CallHistory();
|
||||
|
||||
void Write(
|
||||
OEM_FUNCTION fid,
|
||||
uint64_t start_time,
|
||||
uint64_t end_time,
|
||||
const uint8_t* meta_data,
|
||||
size_t meta_data_length);
|
||||
|
||||
void Read(std::vector<uint8_t>& output) const;
|
||||
|
||||
private:
|
||||
CircularBuffer buffer_;
|
||||
|
||||
uint64_t time_at_head_;
|
||||
uint64_t time_at_tail_;
|
||||
|
||||
bool RequestSpace(uint8_t num_bytes);
|
||||
|
||||
bool ReadNextEntryRealEndTime(uint64_t* output);
|
||||
|
||||
bool DropLastEntry();
|
||||
|
||||
// Read a variable length value. This is the read that matches
|
||||
// EntryWriter's WriteVLV.
|
||||
int ReadVLV(size_t offset, uint64_t* output) const;
|
||||
};
|
||||
|
||||
} // namespace oemprofiler
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif
|
||||
49
libwvdrmengine/cdm/profiler/include/call_table.h
Normal file
49
libwvdrmengine/cdm/profiler/include/call_table.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#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
|
||||
@@ -14,26 +14,16 @@ namespace oemprofiler {
|
||||
class ProfiledScope {
|
||||
public:
|
||||
explicit ProfiledScope(OEM_FUNCTION fid);
|
||||
explicit ProfiledScope(uint32_t sid, OEM_FUNCTION fid);
|
||||
~ProfiledScope();
|
||||
|
||||
EntryWriter meta_data_;
|
||||
|
||||
// All profiling data must be assigned to a session but some oem
|
||||
// crypto calls are not associated with crypto sessions. To gather
|
||||
// those functions' data, the global session id is used. Crypto.Session
|
||||
// Ids are unsigned 32 bit integers. To use those as a profiling session
|
||||
// id but also allow for a global id that won't conflict with them,
|
||||
// we use a -1 as the a proifiling session id is a signed 64 bit integer.
|
||||
static const int64_t kGlobalSID = -1;
|
||||
|
||||
private:
|
||||
int64_t sid_;
|
||||
OEM_FUNCTION fid_;
|
||||
|
||||
uint64_t start_time_;
|
||||
|
||||
void Submit(int64_t sid, uint64_t end_time) const;
|
||||
void Submit(uint64_t end_time) const;
|
||||
uint64_t GetNowUS() const;
|
||||
|
||||
// disallow copy and assign
|
||||
|
||||
25
libwvdrmengine/cdm/profiler/include/profiler.h
Normal file
25
libwvdrmengine/cdm/profiler/include/profiler.h
Normal file
@@ -0,0 +1,25 @@
|
||||
// Copyright 2016 Google Inc. All Rights Reserved.
|
||||
|
||||
#ifndef WVCDM_PROFILER_H_
|
||||
#define WVCDM_PROFILER_H_
|
||||
|
||||
#include "call_table.h"
|
||||
#include "call_history.h"
|
||||
|
||||
namespace wvcdm {
|
||||
namespace oemprofiler {
|
||||
|
||||
class Profiler {
|
||||
public:
|
||||
static CallTable& GetTable();
|
||||
static CallHistory& GetHistory();
|
||||
|
||||
private:
|
||||
static CallTable global_table_;
|
||||
static CallHistory global_history_;
|
||||
};
|
||||
|
||||
} // namespace oemprofiler
|
||||
} // namespace wvcdm
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user