Added test tool

This commit is contained in:
Alexey Milovidov 2020-04-19 23:57:34 +03:00
parent 71c4418876
commit 1c00953b3e
3 changed files with 28 additions and 0 deletions

View File

@ -11,6 +11,8 @@ namespace DB
* *
* Note: a class is used instead of a single function to avoid excessive file open/close on every use. * Note: a class is used instead of a single function to avoid excessive file open/close on every use.
* pread is used to avoid lseek. * pread is used to avoid lseek.
*
* Actual performance is from 1 to 5 million iterations per second.
*/ */
class MemoryStatisticsOS class MemoryStatisticsOS
{ {

View File

@ -68,3 +68,6 @@ target_link_libraries (symbol_index PRIVATE clickhouse_common_io)
add_executable (chaos_sanitizer chaos_sanitizer.cpp) add_executable (chaos_sanitizer chaos_sanitizer.cpp)
target_link_libraries (chaos_sanitizer PRIVATE clickhouse_common_io) target_link_libraries (chaos_sanitizer PRIVATE clickhouse_common_io)
add_executable (memory_statistics_os_perf memory_statistics_os_perf.cpp)
target_link_libraries (memory_statistics_os_perf PRIVATE clickhouse_common_io)

View File

@ -0,0 +1,23 @@
#include <Common/MemoryStatisticsOS.h>
#include <iostream>
int main(int argc, char ** argv)
{
using namespace DB;
size_t num_iterations = argc >= 2 ? std::stoull(argv[1]) : 1000000;
MemoryStatisticsOS stats;
uint64_t counter = 0;
for (size_t i = 0; i < num_iterations; ++i)
{
MemoryStatisticsOS::Data data = stats.get();
counter += data.resident;
}
std::cerr << (counter / num_iterations) << '\n';
return 0;
}