Fix #116 add configure.h for libmemcachedprotocol
[awesomized/libmemcached] / src / bin / memstat.cc
index 5208fb4da16d26d3fa4f8cd903fbb5367c6b2f60..328936a15ab358ee136fdfe4906be95634f62a48 100644 (file)
@@ -1,6 +1,6 @@
 /*
     +--------------------------------------------------------------------+
-    | libmemcached - C/C++ Client Library for memcached                  |
+    | libmemcached-awesome - C/C++ Client Library for memcached          |
     +--------------------------------------------------------------------+
     | Redistribution and use in source and binary forms, with or without |
     | modification, are permitted under the terms of the BSD license.    |
@@ -9,7 +9,7 @@
     | the terms online at: https://opensource.org/licenses/BSD-3-Clause  |
     +--------------------------------------------------------------------+
     | Copyright (c) 2006-2014 Brian Aker   https://datadifferential.com/ |
-    | Copyright (c) 2020 Michael Wallner   <mike@php.net>                |
+    | Copyright (c) 2020-2021 Michael Wallner        https://awesome.co/ |
     +--------------------------------------------------------------------+
 */
 
 #define PROGRAM_DESCRIPTION "Print stats/version of or analyze a memcached cluster."
 #define PROGRAM_VERSION     "1.1"
 
+#define DEFAULT_LATENCY_ITERATIONS 100 // update help string, if changed
+
 #include "common/options.hpp"
 #include "common/checks.hpp"
-#include "common/utilities.h"
+#include "common/time.hpp"
 
 #include <cstdio>
-#include <chrono>
 #include <iomanip>
 
 static memcached_return_t print_server_version(const memcached_st *,
@@ -83,11 +84,6 @@ static bool analyze_stat(const client_options &opt, memcached_st *memc, memcache
   return true;
 }
 
-using time_clock = std::chrono::high_resolution_clock;
-using time_point = std::chrono::time_point<time_clock>;
-using time_format = std::chrono::duration<double, std::ratio<1,1>>;
-using time_format_ms = std::chrono::duration<double, std::ratio<1,1000>>;
-
 static void latency_test(uint32_t iterations, std::vector<memcached_st> &servers) {
   const char *test_key = "libmemcached_test_key";
   size_t test_key_len = strlen(test_key);
@@ -146,7 +142,7 @@ static void latency_test(uint32_t iterations, std::vector<memcached_st> &servers
 }
 
 static bool analyze_latency(client_options &opt, memcached_st *root) {
-  uint32_t num_of_tests = 100;
+  uint32_t num_of_tests = DEFAULT_LATENCY_ITERATIONS;
 
   if (auto iter_str = opt.argof("iterations")) {
     num_of_tests = std::stoul(iter_str);