Skip to content

Commit

Permalink
Add file and stdout output
Browse files Browse the repository at this point in the history
  • Loading branch information
debermudez committed Aug 2, 2023
1 parent 32b4331 commit d2ff5f9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/c++/perf_analyzer/raw_data_reporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@

#include "raw_data_reporter.h"

#include <rapidjson/filewritestream.h>
#include <rapidjson/ostreamwrapper.h>
#include <rapidjson/writer.h>

#include "client_backend/client_backend.h"

namespace triton { namespace perfanalyzer {
Expand Down Expand Up @@ -143,8 +147,27 @@ RawDataReporter::AddVersion(std::string& raw_version)
document_.AddMember("version", version, document_.GetAllocator());
}

// print to std::cout
// print to file

void
RawDataReporter::Print()
{
OStreamWrapper out(std::cout);
Writer<OStreamWrapper> writer(out);
document_.Accept(writer);
}

void
RawDataReporter::OutputToFile()
{
FILE* fp = fopen("fix_me", "w");
char writeBuffer[65536];
FileWriteStream os(fp, writeBuffer, sizeof(writeBuffer));

Writer<FileWriteStream> writer(os);
document_.Accept(writer);

fclose(fp);
}

}} // namespace triton::perfanalyzer
5 changes: 5 additions & 0 deletions src/c++/perf_analyzer/raw_data_reporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ class RawDataReporter {
void ConvertToJson(
std::vector<Experiment>& raw_experiments, std::string& raw_version);

/// Output to stdout
void Print();

void OutputToFile();

private:
RawDataReporter() = default;
void ClearDocument();
Expand Down

0 comments on commit d2ff5f9

Please sign in to comment.