| 42 | } |
| 43 | |
| 44 | void ProgressTracker::work() { |
| 45 | auto now = std::chrono::system_clock::now(); |
| 46 | auto nowTimeT = std::chrono::system_clock::to_time_t(now); |
| 47 | char buf[16]; |
| 48 | struct tm time; |
| 49 | ::localtime_r(&nowTimeT, &time); |
| 50 | ::strftime(buf, sizeof(buf), "%H:%M:%S", &time); |
| 51 | auto throughputStats = stressor_.aggregateThroughputStats(); |
| 52 | auto mOpsPerSec = throughputStats.ops / 1e6; |
| 53 | |
| 54 | auto currCacheStats = stressor_.getCacheStats(); |
| 55 | auto thStr = fmt::format("Instance {:>3}: {} {:>10.2f}M ops completed. {}", |
| 56 | instanceId_, |
| 57 | buf, |
| 58 | mOpsPerSec, |
| 59 | currCacheStats->progress(*prevStats_)); |
| 60 | |
| 61 | // additionally log into the stats file |
| 62 | if (statsFile_.is_open()) { |
| 63 | statsFile_ << thStr << std::endl; |
| 64 | statsFile_ << "== Allocator Stats ==" << std::endl; |
| 65 | currCacheStats->render(statsFile_); |
| 66 | |
| 67 | statsFile_ << "== Hit Ratio Stats Since Last ==" << std::endl; |
| 68 | currCacheStats->render(*prevStats_, statsFile_); |
| 69 | |
| 70 | statsFile_ << "== Throughput Stats ==" << std::endl; |
| 71 | auto elapsedTimeNs = stressor_.getTestDurationNs(); |
| 72 | throughputStats.render(elapsedTimeNs, statsFile_); |
| 73 | |
| 74 | stressor_.renderWorkloadGeneratorStats(elapsedTimeNs, statsFile_); |
| 75 | statsFile_ << std::endl; |
| 76 | } else { |
| 77 | std::cout << thStr << std::endl; |
| 78 | } |
| 79 | |
| 80 | prevStats_ = std::move(currCacheStats); |
| 81 | } |
| 82 | } // namespace cachebench |
| 83 | } // namespace cachelib |
| 84 | } // namespace facebook |
nothing calls this directly
no test coverage detected