Merge pull request #1206 from emankov/master
[HIPIFY] Statistics to CSV file dumping revise
This commit is contained in:
@@ -104,6 +104,11 @@ cl::opt<bool> PrintStats("print-stats",
|
||||
cl::value_desc("print-stats"),
|
||||
cl::cat(ToolTemplateCategory));
|
||||
|
||||
cl::opt<bool> PrintStatsCSV("print-stats-csv",
|
||||
cl::desc("Print translation statistics in CSV file"),
|
||||
cl::value_desc("print-stats-csv"),
|
||||
cl::cat(ToolTemplateCategory));
|
||||
|
||||
cl::opt<std::string> OutputStatsFilename("o-stats",
|
||||
cl::desc("Output filename for statistics"),
|
||||
cl::value_desc("filename"),
|
||||
|
||||
@@ -46,6 +46,7 @@ extern cl::opt<bool> Verbose;
|
||||
extern cl::opt<bool> NoBackup;
|
||||
extern cl::opt<bool> NoOutput;
|
||||
extern cl::opt<bool> PrintStats;
|
||||
extern cl::opt<bool> PrintStatsCSV;
|
||||
extern cl::opt<std::string> OutputStatsFilename;
|
||||
extern cl::opt<bool> Examine;
|
||||
extern cl::extrahelp CommonHelp;
|
||||
|
||||
@@ -291,7 +291,7 @@ int main(int argc, const char **argv) {
|
||||
}
|
||||
int Result = 0;
|
||||
SmallString<128> tmpFile;
|
||||
StringRef sourceFileName, ext = "hip";
|
||||
StringRef sourceFileName, ext = "hip", csv_ext = "csv";
|
||||
std::string sTmpFileName, sSourceAbsPath;
|
||||
std::string sTmpDirAbsParh = getAbsoluteDirectoryPath(TemporaryDir, EC);
|
||||
if (EC) {
|
||||
@@ -300,7 +300,20 @@ int main(int argc, const char **argv) {
|
||||
// Arguments for the Statistics print routines.
|
||||
std::unique_ptr<std::ostream> csv = nullptr;
|
||||
llvm::raw_ostream* statPrint = nullptr;
|
||||
bool create_csv = false;
|
||||
if (!OutputStatsFilename.empty()) {
|
||||
PrintStatsCSV = true;
|
||||
create_csv = true;
|
||||
} else {
|
||||
if (PrintStatsCSV && fileSources.size() > 1) {
|
||||
OutputStatsFilename = "sum_stat.csv";
|
||||
create_csv = true;
|
||||
}
|
||||
}
|
||||
if (create_csv) {
|
||||
if (!OutputDir.empty()) {
|
||||
OutputStatsFilename = sOutputDirAbsPath + "/" + OutputStatsFilename;
|
||||
}
|
||||
csv = std::unique_ptr<std::ostream>(new std::ofstream(OutputStatsFilename, std::ios_base::trunc));
|
||||
}
|
||||
if (PrintStats) {
|
||||
@@ -342,6 +355,17 @@ int main(int argc, const char **argv) {
|
||||
Result = 1;
|
||||
continue;
|
||||
}
|
||||
if (PrintStatsCSV) {
|
||||
if (OutputStatsFilename.empty()) {
|
||||
OutputStatsFilename = sourceFileName.str() + "." + csv_ext.str();
|
||||
if (!OutputDir.empty()) {
|
||||
OutputStatsFilename = sOutputDirAbsPath + "/" + OutputStatsFilename;
|
||||
}
|
||||
}
|
||||
if (!csv) {
|
||||
csv = std::unique_ptr<std::ostream>(new std::ofstream(OutputStatsFilename, std::ios_base::trunc));
|
||||
}
|
||||
}
|
||||
// Initialise the statistics counters for this file.
|
||||
Statistics::setActive(src);
|
||||
// RefactoringTool operates on the file in-place. Giving it the output path is no good,
|
||||
|
||||
Reference in New Issue
Block a user