From a5a723bfda0404d50077016e95e7cdd9b3f39013 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dominik=20Tomic=CC=8Cevic=CC=81?=
 <dominik.tomicevic@gmail.com>
Date: Sun, 20 Mar 2016 18:39:25 +0100
Subject: [PATCH] fixed query counter issue

---
 demo/worker/benchmark.hpp      | 4 +++-
 demo/worker/benchmark_json.cpp | 6 +++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/demo/worker/benchmark.hpp b/demo/worker/benchmark.hpp
index 80aa854c0..f92343830 100644
--- a/demo/worker/benchmark.hpp
+++ b/demo/worker/benchmark.hpp
@@ -94,6 +94,8 @@ std::string benchmark_json(const std::string& host,
         [](auto acc, auto x) { return acc + x; }
     );
 
+    auto created_count = counter.load();
+
     std::string json = "{\"total\":" + std::to_string(total / elapsed) + ","
         + " \"per_query\": [";
     for(size_t i = 0; i < queries.size(); ++i) {
@@ -103,6 +105,6 @@ std::string benchmark_json(const std::string& host,
         }
         json += ", " + std::to_string(reqs[i] / elapsed);
     }
-    json += "]}";
+    json += "], \"counter\": " + std::to_string(created_count) + " }";
     return json;
 }
diff --git a/demo/worker/benchmark_json.cpp b/demo/worker/benchmark_json.cpp
index 86df1e663..f40ec5dc8 100644
--- a/demo/worker/benchmark_json.cpp
+++ b/demo/worker/benchmark_json.cpp
@@ -10,8 +10,12 @@ int main(int argc, char* argv[])
     auto port        = std::string(argv[2]);
     auto connections = std::stoi(argv[3]);
     auto duration    = std::stod(argv[4]);
+    auto count       = std::stoi(argv[5]);
+
+    counter.store(count);
+
     std::vector<std::string> queries;
-    for (int i = 5; i <  argc; ++i) {
+    for (int i = 6; i <  argc; ++i) {
         queries.emplace_back(std::string(argv[i]));
     }