Skip to content

Commit

Permalink
Merge pull request google#2 from rauls5382/unused
Browse files Browse the repository at this point in the history
Remove profile_wrappers and unused functions
  • Loading branch information
rauls5382 authored Oct 3, 2016
2 parents 4258c4b + d5ec07f commit 58d6c37
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 152 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ LIBRARY_SOURCES = $(QUIPPER_LIBRARY_SOURCES) $(CONVERTER_LIBRARY_SOURCES)

QUIPPER_PROTOS = perf_data.proto perf_stat.proto
QUIPPER_PROTOS := $(QUIPPER_PROTOS:%=${CWP}/%)
CONVERTER_PROTOS = profile.proto profile_wrappers.proto
CONVERTER_PROTOS = profile.proto
QUIPPER_GENERATED_SOURCES = $(QUIPPER_PROTOS:.proto=.pb.cc)
QUIPPER_GENERATED_HEADERS = $(QUIPPER_PROTOS:.proto=.pb.h)
GENERATED_SOURCES = $(CONVERTER_PROTOS:.proto=.pb.cc) \
Expand Down
67 changes: 1 addition & 66 deletions perf_data_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include "int_compat.h"
#include "intervalmap.h"
#include "perf_data_handler.h"
#include "profile_wrappers.pb.h"
#include "string_compat.h"

namespace perftools {
Expand Down Expand Up @@ -513,21 +512,6 @@ ProfileVector PerfDataConverter::Profiles() {
return profiles;
}

// Returns the provided ProfileVector as a serialized proto.
string SerializedProfileList(const ProfileVector& vec) {
ProfileList list;
for (const auto& profile : vec) {
*list.add_profile() = *profile;
}

string serialized_out;
if (!list.SerializeToString(&serialized_out)) {
std::cerr << "Failed to serialize ProfileList" << std::endl;
abort();
}
return serialized_out;
}

ProfileVector PerfDataProtoToProfileList(quipper::PerfDataProto* perf_data,
uint32 sample_labels,
bool group_by_pids) {
Expand All @@ -539,8 +523,7 @@ ProfileVector PerfDataProtoToProfileList(quipper::PerfDataProto* perf_data,
} // namespace

ProfileVector RawPerfDataToProfileProto(const void* raw, int raw_size,
const void* build_ids,
int build_ids_size,
const std::map<string, string> &build_id_map,
uint32 sample_labels,
bool group_by_pids) {
std::unique_ptr<quipper::PerfReader> reader(new quipper::PerfReader);
Expand All @@ -556,15 +539,6 @@ ProfileVector RawPerfDataToProfileProto(const void* raw, int raw_size,
return ProfileVector();
}

StringMap build_id_map_pb;
if (!build_id_map_pb.ParseFromArray(build_ids, build_ids_size)) {
std::cerr << "Unable to parse build ids." << std::endl;
abort();
}
std::map<string, string> build_id_map;
for (const auto& item : build_id_map_pb.key_value()) {
build_id_map[item.key()] = item.value();
}
reader->InjectBuildIDs(build_id_map);
// Perf populates info about the kernel using multiple pathways,
// which don't actually all match up how they name kernel data; in
Expand All @@ -591,43 +565,4 @@ ProfileVector SerializedPerfDataProtoToProfileProto(
return PerfDataProtoToProfileList(&perf_data, sample_labels, group_by_pids);
}

// Returns a serialized ProfileList following the semantics of
// RawPerfDataToProfileProto
string RawPerfDataToSerializedProfileList(const void* raw, int raw_size,
const void* build_ids,
int build_ids_size,
uint32 sample_labels,
bool group_by_pids) {
const auto& profiles = RawPerfDataToProfileProto(
raw, raw_size, build_ids, build_ids_size, sample_labels, group_by_pids);
return SerializedProfileList(profiles);
}

string RawPerfDataUniqueMappedFiles(const void* raw, int raw_size) {
std::unique_ptr<quipper::PerfReader> reader(new quipper::PerfReader);
if (!reader->ReadFromPointer(reinterpret_cast<const char*>(raw), raw_size)) {
LOG(ERROR) << "Could not read input perf.data";
return "";
}
std::vector<string> filenames;
reader->GetFilenames(&filenames);
StringList list;
for (const auto& filename : filenames) {
list.add_item(filename);
}
string serialized;
if (!list.SerializeToString(&serialized)) {
std::cerr << "Failed to serialize StringList" << std::endl;
abort();
}
return serialized;
}

string SerializedPerfDataProtoToSerializedProfileList(
const string& perf_data_str, uint32 sample_labels) {
const auto& profiles =
SerializedPerfDataProtoToProfileProto(perf_data_str, sample_labels);
return SerializedProfileList(profiles);
}

} // namespace perftools
15 changes: 3 additions & 12 deletions perf_data_converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ const char ExecutionModeHypervisor[] = "Hypervisor";
//
// Returns an empty vector if any error occurs.
extern std::vector<std::unique_ptr<perftools::profiles::Profile> >
RawPerfDataToProfileProto(const void* raw, int raw_size, const void* build_ids,
int build_ids_size, uint32 sample_labels = kNoLabels,
RawPerfDataToProfileProto(const void* raw, int raw_size,
const std::map<string, string> &build_id_map,
uint32 sample_labels = kNoLabels,
bool group_by_pids = true);

extern std::vector<std::unique_ptr<perftools::profiles::Profile> >
Expand All @@ -94,16 +95,6 @@ SerializedPerfDataProtoToProfileProto(const string& serialized_perf_data,
// raw perf.data.
string RawPerfDataUniqueMappedFiles(const void* raw, int raw_size);

// Returns a serialized ProfileList following the semantics of
// RawPerfDataToProfileProto
string RawPerfDataToSerializedProfileList(const void* raw_perf_data,
int raw_size, const void* build_ids,
int build_ids_size,
uint32 sample_labels = kNoLabels,
bool group_by_pids = true);

string SerializedPerfDataProtoToSerializedProfileList(
const string& perf_data_str, uint32 sample_labels = kNoLabels);
} // namespace perftools

#endif // PERFTOOLS_PERF_DATA_CONVERTER_H_
19 changes: 6 additions & 13 deletions perf_data_converter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,10 @@ TEST_F(PerfDataConverterTest, Converts) {
GetContents(c.filename, &raw_perf_data);

// Test RawPerfData input.
std::map<string, string> build_ids;
ProfileVector profiles = RawPerfDataToProfileProto(
reinterpret_cast<const void*>(raw_perf_data.c_str()),
raw_perf_data.size(), nullptr, 0, kNoLabels, false);
raw_perf_data.size(), build_ids, kNoLabels, false);
// Does not group by PID, Vector should only contain one element
EXPECT_EQ(profiles.size(), 1);
auto counts = GetMapCounts(profiles);
Expand Down Expand Up @@ -287,22 +288,14 @@ TEST_F(PerfDataConverterTest, Injects) {
string raw_perf_data;
GetContents(path, &raw_perf_data);
const string want_buildid = "abcdabcd";
perftools::StringMap string_map;
string_map.add_key_value();
string_map.mutable_key_value(0)->set_key("[kernel.kallsyms]");
string_map.mutable_key_value(0)->set_value(want_buildid);
string serialized_string_map;
if (!string_map.SerializeToString(&serialized_string_map)) {
std::cerr << "Failed to serizlied string_map to string." << std::endl;
abort();
}
std::map<string, string> build_ids;
build_ids["[kernel.kallsyms]"] = want_buildid;

// Test RawPerfData input.
ProfileVector profiles = RawPerfDataToProfileProto(
reinterpret_cast<const void*>(raw_perf_data.c_str()),
raw_perf_data.size(),
reinterpret_cast<const void*>(serialized_string_map.c_str()),
serialized_string_map.size(), kNoLabels, false);
raw_perf_data.size(), build_ids,
kNoLabels, false);
bool found = false;
for (const auto& profile : profiles) {
for (const auto& it : profile->mapping()) {
Expand Down
4 changes: 3 additions & 1 deletion perf_to_profile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ int main(int argc, char **argv) {
}
const auto perf_data = ReadFileToString(argv[1]);
const auto raw_perf_data = static_cast<const void *>(perf_data.data());

std::map<string, string> build_ids;
const ProfileVector profiles = perftools::RawPerfDataToProfileProto(
raw_perf_data, perf_data.length(), nullptr, 0, perftools::kNoLabels,
raw_perf_data, perf_data.length(), build_ids, perftools::kNoLabels,
false);
// group_by_pid is false, all of the PID profiles should be merged into a
// single one.
Expand Down
59 changes: 0 additions & 59 deletions profile_wrappers.proto

This file was deleted.

0 comments on commit 58d6c37

Please sign in to comment.