MCPcopy Create free account
hub / github.com/PlatformLab/NanoLog / main

Function main

benchmarks/Benchmark.cc:95–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95int main(int argc, char** argv) {
96 // Optional: Set the output location for the NanoLog system. By default
97 // the log will be output to /tmp/compressedLog
98 // NanoLog::setLogFile("/tmp/logFile");
99 NanoLog::setLogFile(BENCHMARK_OUTPUT_FILE);
100
101 printf("BENCH_OP = %s\r\n", BENCH_OPS_AS_A_STR);
102
103#ifdef PREPROCESSOR_NANOLOG
104 constexpr const char system[] = "PreProc";
105#else
106 constexpr const char system[] = "C++17";
107#endif
108 printf("NanoLog System: %s\r\n", system);
109
110#ifdef BENCHMARK_DISCARD_ENTRIES_AT_STAGINGBUFFER
111 constexpr const char discard[] = "true";
112#else
113 constexpr const char discard[] = "false";
114#endif
115
116 pthread_barrier_t barrier;
117 if (pthread_barrier_init(&barrier, NULL, BENCHMARK_THREADS)) {
118 printf("pthread error\r\n");
119 }
120
121 std::vector<std::thread> threads;
122 threads.reserve(BENCHMARK_THREADS);
123 for (int i = 1; i < BENCHMARK_THREADS; ++i)
124 threads.emplace_back(runBenchmark, i, &barrier);
125
126 uint64_t start = PerfUtils::Cycles::rdtsc();
127 runBenchmark(0, &barrier);
128
129 for (int i = 0; i < threads.size(); ++i)
130 if (threads[i].joinable())
131 threads.at(i).join();
132
133 uint64_t syncStart = PerfUtils::Cycles::rdtsc();
134 // Flush all pending log messages to disk
135 NanoLog::sync();
136 uint64_t stop = PerfUtils::Cycles::rdtsc();
137
138 double time = PerfUtils::Cycles::toSeconds(stop - syncStart);
139 printf("Flushing the log statements to disk took an additional %0.2lf secs\r\n",
140 time);
141
142 uint64_t totalEvents = NanoLogInternal::RuntimeLogger::nanoLogSingleton.logsProcessed;
143 double totalTime = PerfUtils::Cycles::toSeconds(stop - start);
144 double recordTimeEstimated = PerfUtils::Cycles::toSeconds(stop - start
145 - NanoLogInternal::RuntimeLogger::stagingBuffer->cyclesProducerBlocked);
146 double recordNsEstimated = recordTimeEstimated*1.0e9
147 / NanoLogInternal::RuntimeLogger::stagingBuffer->numAllocations;
148 double compressionTime = PerfUtils::Cycles::toSeconds(
149 NanoLogInternal::RuntimeLogger::nanoLogSingleton.cyclesCompressing);
150 printf("Took %0.2lf seconds to log %lu operations\r\nThroughput: %0.2lf op/s (%0.2lf Mop/s)\r\n",
151 totalTime, totalEvents,
152 totalEvents/totalTime,

Callers

nothing calls this directly

Calls 7

setLogFileFunction · 0.85
rdtscFunction · 0.85
syncFunction · 0.85
getStatsFunction · 0.85
printConfigFunction · 0.85
reserveMethod · 0.80
runBenchmarkFunction · 0.70

Tested by

no test coverage detected