Update hashrate time
Use the modern chrono lib to get the hashrate time
This commit is contained in:
parent
f6fe59ba17
commit
f9ab781df1
2 changed files with 23 additions and 3 deletions
|
@ -22,8 +22,13 @@
|
|||
*/
|
||||
|
||||
#ifndef _WIN32
|
||||
#if __cplusplus <= 199711L
|
||||
#include <sys/time.h>
|
||||
#else
|
||||
#include <chrono>
|
||||
#define USE_CHRONO
|
||||
#endif
|
||||
#else
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#include <stdint.h> // portable: uint64_t MSVC: __int64
|
||||
|
@ -114,9 +119,14 @@ double Hashrate::calc(size_t ms) const
|
|||
|
||||
double Hashrate::calc(size_t threadId, size_t ms) const
|
||||
{
|
||||
#ifdef USE_CHRONO
|
||||
using namespace std::chrono;
|
||||
const uint64_t now = time_point_cast<milliseconds>(high_resolution_clock::now()).time_since_epoch().count();
|
||||
#else
|
||||
struct timeval tp;
|
||||
gettimeofday(&tp, NULL);
|
||||
uint64_t now = tp.tv_sec * 1000 + tp.tv_usec / 1000;
|
||||
const uint64_t now = tp.tv_sec * 1000 + tp.tv_usec / 1000;
|
||||
#endif
|
||||
|
||||
uint64_t earliestHashCount = 0;
|
||||
uint64_t earliestStamp = 0;
|
||||
|
|
|
@ -28,8 +28,13 @@
|
|||
#include "workers/Worker.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
#if __cplusplus <= 199711L
|
||||
#include <sys/time.h>
|
||||
#else
|
||||
#include <chrono>
|
||||
#define USE_CHRONO
|
||||
#endif
|
||||
#else
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#include <stdint.h> // portable: uint64_t MSVC: __int64
|
||||
|
@ -82,10 +87,15 @@ Worker::~Worker()
|
|||
|
||||
void Worker::storeStats()
|
||||
{
|
||||
#ifdef USE_CHRONO
|
||||
using namespace std::chrono;
|
||||
const uint64_t now = time_point_cast<milliseconds>(high_resolution_clock::now()).time_since_epoch().count();
|
||||
#else
|
||||
struct timeval tp;
|
||||
gettimeofday(&tp, NULL);
|
||||
uint64_t timestamp = tp.tv_sec * 1000 + tp.tv_usec / 1000;
|
||||
const uint64_t now = tp.tv_sec * 1000 + tp.tv_usec / 1000;
|
||||
#endif
|
||||
|
||||
m_hashCount = m_count;
|
||||
m_timestamp = timestamp;
|
||||
m_timestamp = now;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue