dbms: benchmark: better [#METR-2944].

This commit is contained in:
Alexey Milovidov 2014-04-07 03:18:07 +04:00
parent d986afc319
commit d8cf48d765

View File

@ -63,6 +63,8 @@ public:
readQueries(); readQueries();
run(); run();
std::cerr << "\nTotal queries executed: " << queries_total << std::endl;
} }
private: private:
@ -82,10 +84,11 @@ private:
DataTypeFactory data_type_factory; DataTypeFactory data_type_factory;
ConnectionPool connections; ConnectionPool connections;
Stopwatch total_watch; Stopwatch watch_per_interval;
size_t total_queries = 0; size_t queries_total = 0;
size_t total_rows = 0; size_t queries_per_interval = 0;
size_t total_bytes = 0; size_t rows_per_interval = 0;
size_t bytes_per_interval = 0;
ReservoirSampler<double> sampler {1 << 16}; ReservoirSampler<double> sampler {1 << 16};
Poco::FastMutex mutex; Poco::FastMutex mutex;
@ -118,7 +121,7 @@ private:
InterruptListener interrupt_listener; InterruptListener interrupt_listener;
total_watch.restart(); watch_per_interval.restart();
Stopwatch watch; Stopwatch watch;
/// В цикле, кладём все запросы в очередь. /// В цикле, кладём все запросы в очередь.
@ -221,9 +224,10 @@ private:
{ {
Poco::ScopedLock<Poco::FastMutex> lock(mutex); Poco::ScopedLock<Poco::FastMutex> lock(mutex);
++total_queries; ++queries_total;
total_rows += rows; ++queries_per_interval;
total_bytes += bytes; rows += rows_per_interval;
bytes += bytes_per_interval;
sampler.insert(seconds); sampler.insert(seconds);
} }
@ -234,15 +238,25 @@ private:
std::cerr std::cerr
<< std::endl << std::endl
<< "QPS: " << (total_queries / total_watch.elapsedSeconds()) << ", " << "QPS: " << (queries_per_interval / watch_per_interval.elapsedSeconds()) << ", "
<< "RPS: " << (total_rows / total_watch.elapsedSeconds()) << ", " << "RPS: " << (rows_per_interval / watch_per_interval.elapsedSeconds()) << ", "
<< "MiB/s: " << (total_bytes / total_watch.elapsedSeconds() / 1048576) << "." << "MiB/s: " << (bytes_per_interval / watch_per_interval.elapsedSeconds() / 1048576) << "."
<< std::endl; << std::endl;
for (size_t percent = 0; percent <= 100; percent += 10) for (size_t percent = 0; percent <= 100; percent += 10)
std::cerr << percent << "%\t" << sampler.quantileInterpolated(percent / 100.0) << " sec." << std::endl; std::cerr << percent << "%\t" << sampler.quantileInterpolated(percent / 100.0) << " sec." << std::endl;
resetCounts();
}
void resetCounts()
{
sampler.clear(); sampler.clear();
queries_per_interval = 0;
rows_per_interval = 0;
bytes_per_interval = 0;
watch_per_interval.restart();
} }
}; };