Skip to content

Commit

Permalink
XrdApps::JCache: fix Art ASCII plot with time vs rate plot
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Joachim Peters committed Jun 10, 2024
1 parent 1a73711 commit 3e521ce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/XrdApps/XrdClJCachePlugin/file/Art.hh
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ public:
// Print the plot with Y legend
for (int i = 0; i < plotHeight; ++i) {
double yValue = minValue + (maxValue - minValue) * (plotHeight - 1 - i) / (plotHeight - 1);
std::cout << std::setw(yLegendWidth) << std::fixed << std::setprecision(2) << yValue << " | ";
std::cout << std::setw(yLegendWidth) << std::fixed << std::setprecision(2) << yValue << " MB/s | ";
std::cout << plot[i] << std::endl;
}

// Print the X axis
std::cout << std::string(yLegendWidth + 3, ' ') << std::string(plotWidth, '-') << std::endl;
std::cout << std::string(yLegendWidth + 3, ' ') << "0 1 2 3 4 5 6 7 8 9" << std::endl;
std::cout << std::string(yLegendWidth + 7, ' ') << std::string(plotWidth, '-') << std::endl;
std::cout << std::string(yLegendWidth + 7, ' ') << "0 1 2 3 4 5 6 7 8 9" << std::endl;
}

void drawCurve(const std::vector<long unsigned int>& data, double interval) {
Expand Down
13 changes: 4 additions & 9 deletions src/XrdApps/XrdClJCachePlugin/file/XrdClJCacheFile.hh
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,6 @@ public:
oss << "# JCache : app readrate : " << std::fixed << std::setprecision(2) << sStats.bytesToHumanReadable((sStats.ReadBytes()/sStats.realTime)) << "/s" << std::endl;
oss << "# ----------------------------------------------------------- #" << std::endl;

using namespace std::chrono;

std::vector<uint64_t> bins = sStats.bench.GetBins();

for (size_t i = 0; i < bins.size(); ++i) {
std::cout << "Bin " << i + 1 << ": " << bins[i] << " bytes" << std::endl;
}
Art art;
art.drawCurve(bins, sStats.bench.GetTimePerBin().count() / 1000000.0);
return oss.str();
}
//! structure about cache hit statistics
Expand All @@ -355,6 +346,10 @@ public:
~CacheStats() {
if (dumponexit.load()) {
std::cerr << GlobalStats();
using namespace std::chrono;
std::vector<uint64_t> bins = sStats.bench.GetBins();
Art art;
art.drawCurve(bins, sStats.bench.GetTimePerBin().count() / 1000000.0);
}
}

Expand Down

0 comments on commit 3e521ce

Please sign in to comment.