Skip to content

Commit

Permalink
Augmented DataAnalyzerResult::to_csv with const string.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmuehlig committed Nov 8, 2024
1 parent bcc4293 commit 2391cca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 7 additions & 3 deletions include/perfcpp/analyzer/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,13 @@ class DataAnalyzerResult
[[nodiscard]] const std::vector<DataType>& data_types() const noexcept { return _data_types; }
[[nodiscard]] std::vector<DataType>& data_types() noexcept { return _data_types; }

[[nodiscard]] std::string to_string() const noexcept;
[[nodiscard]] std::string to_json() const noexcept;
[[nodiscard]] std::string to_csv(std::string&& data_type_name, char delimiter = ',', bool print_header = true) const noexcept;
[[nodiscard]] std::string to_string() const;
[[nodiscard]] std::string to_json() const;
[[nodiscard]] std::string to_csv(const std::string& data_type_name, char delimiter = ',', bool print_header = true) const;
[[nodiscard]] std::string to_csv(std::string&& data_type_name, const char delimiter = ',', const bool print_header = true) const
{
return to_csv(data_type_name, delimiter, print_header);
}

private:
std::vector<DataType> _data_types;
Expand Down
8 changes: 4 additions & 4 deletions src/analyzer/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ perf::analyzer::DataAnalyzer::map(const std::vector<Sample>& samples)
}

std::string
perf::analyzer::DataAnalyzerResult::to_string() const noexcept
perf::analyzer::DataAnalyzerResult::to_string() const
{
auto column_headers = std::vector<std::string>{
"", "", "samples", "loads", "avg. load lat.", "L1d hits", "LFB hits",
Expand Down Expand Up @@ -188,7 +188,7 @@ perf::analyzer::DataAnalyzerResult::to_string() const noexcept
}

std::string
perf::analyzer::DataAnalyzerResult::to_json() const noexcept
perf::analyzer::DataAnalyzerResult::to_json() const
{
auto stream = std::stringstream{};
stream << "[";
Expand Down Expand Up @@ -243,9 +243,9 @@ perf::analyzer::DataAnalyzerResult::to_json() const noexcept
}

std::string
perf::analyzer::DataAnalyzerResult::to_csv(std::string&& data_type_name,
perf::analyzer::DataAnalyzerResult::to_csv(const std::string& data_type_name,
const char delimiter,
const bool print_header) const noexcept
const bool print_header) const
{
auto stream = std::stringstream{};

Expand Down

0 comments on commit 2391cca

Please sign in to comment.