diff --git a/ixbots/ixbots/IXCobraBot.cpp b/ixbots/ixbots/IXCobraBot.cpp index b91319a2..ffd8fdba 100644 --- a/ixbots/ixbots/IXCobraBot.cpp +++ b/ixbots/ixbots/IXCobraBot.cpp @@ -36,23 +36,38 @@ namespace ix std::atomic receivedCount(0); std::atomic sentCountTotal(0); std::atomic receivedCountTotal(0); + std::atomic sentCountPerSecs(0); + std::atomic receivedCountPerSecs(0); std::atomic stop(false); std::atomic throttled(false); std::atomic fatalCobraError(false); QueueManager queueManager(maxQueueSize); - auto timer = [&sentCount, &receivedCount, &sentCountTotal, &receivedCountTotal, &stop] { + auto timer = [&sentCount, + &receivedCount, + &sentCountTotal, + &receivedCountTotal, + &sentCountPerSecs, + &receivedCountPerSecs, + &stop] { while (!stop) { + // + // We cannot write to sentCount and receivedCount + // as those are used externally, so we need to introduce + // our own counters + // spdlog::info("messages received {} {} sent {} {}", - receivedCount, receivedCountTotal, sentCount, sentCountTotal); + receivedCountPerSecs, + receivedCountTotal, + sentCountPerSecs, + sentCountTotal); + receivedCountPerSecs = receivedCount - receivedCountTotal; + sentCountPerSecs = sentCount - receivedCountTotal; - receivedCountTotal += receivedCount; - sentCountTotal += sentCount; - - receivedCount = 0; - sentCount = 0; + receivedCountTotal += receivedCountPerSecs; + sentCountTotal += sentCountPerSecs; auto duration = std::chrono::seconds(1); std::this_thread::sleep_for(duration);