mirror of
https://github.com/ShaYmez/MMDVM_CM.git
synced 2025-06-14 11:12:26 -04:00
Update the StopWatch code
This commit is contained in:
parent
d231273c1a
commit
d600b606cd
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2018 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -21,21 +21,32 @@
|
|||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
|
||||||
CStopWatch::CStopWatch() :
|
CStopWatch::CStopWatch() :
|
||||||
m_frequency(),
|
m_frequencyS(),
|
||||||
|
m_frequencyMS(),
|
||||||
m_start()
|
m_start()
|
||||||
{
|
{
|
||||||
::QueryPerformanceFrequency(&m_frequency);
|
::QueryPerformanceFrequency(&m_frequencyS);
|
||||||
|
|
||||||
|
m_frequencyMS.QuadPart = m_frequencyS.QuadPart / 1000ULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CStopWatch::~CStopWatch()
|
CStopWatch::~CStopWatch()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long CStopWatch::start()
|
unsigned long long CStopWatch::time() const
|
||||||
|
{
|
||||||
|
LARGE_INTEGER now;
|
||||||
|
::QueryPerformanceCounter(&now);
|
||||||
|
|
||||||
|
return (unsigned long long)(now.QuadPart / m_frequencyMS.QuadPart);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long long CStopWatch::start()
|
||||||
{
|
{
|
||||||
::QueryPerformanceCounter(&m_start);
|
::QueryPerformanceCounter(&m_start);
|
||||||
|
|
||||||
return (unsigned long)(m_start.QuadPart / m_frequency.QuadPart);
|
return (unsigned long long)(m_start.QuadPart / m_frequencyS.QuadPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int CStopWatch::elapsed()
|
unsigned int CStopWatch::elapsed()
|
||||||
@ -46,15 +57,16 @@ unsigned int CStopWatch::elapsed()
|
|||||||
LARGE_INTEGER temp;
|
LARGE_INTEGER temp;
|
||||||
temp.QuadPart = (now.QuadPart - m_start.QuadPart) * 1000;
|
temp.QuadPart = (now.QuadPart - m_start.QuadPart) * 1000;
|
||||||
|
|
||||||
return (unsigned int)(temp.QuadPart / m_frequency.QuadPart);
|
return (unsigned int)(temp.QuadPart / m_frequencyS.QuadPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
CStopWatch::CStopWatch() :
|
CStopWatch::CStopWatch() :
|
||||||
m_start()
|
m_startMS(0ULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,23 +74,32 @@ CStopWatch::~CStopWatch()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long CStopWatch::start()
|
unsigned long long CStopWatch::time() const
|
||||||
{
|
|
||||||
::gettimeofday(&m_start, NULL);
|
|
||||||
|
|
||||||
return m_start.tv_usec;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int CStopWatch::elapsed()
|
|
||||||
{
|
{
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
::gettimeofday(&now, NULL);
|
::gettimeofday(&now, NULL);
|
||||||
|
|
||||||
unsigned int elapsed = (now.tv_sec - m_start.tv_sec) * 1000U;
|
return now.tv_sec * 1000ULL + now.tv_usec / 1000ULL;
|
||||||
elapsed += now.tv_usec / 1000U;
|
}
|
||||||
elapsed -= m_start.tv_usec / 1000U;
|
|
||||||
|
|
||||||
return elapsed;
|
unsigned long long CStopWatch::start()
|
||||||
|
{
|
||||||
|
struct timespec now;
|
||||||
|
::clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
|
m_startMS = now.tv_sec * 1000ULL + now.tv_nsec / 1000000ULL;
|
||||||
|
|
||||||
|
return m_startMS;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CStopWatch::elapsed()
|
||||||
|
{
|
||||||
|
struct timespec now;
|
||||||
|
::clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
|
unsigned long long nowMS = now.tv_sec * 1000ULL + now.tv_nsec / 1000000ULL;
|
||||||
|
|
||||||
|
return nowMS - m_startMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2018 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -31,15 +31,18 @@ public:
|
|||||||
CStopWatch();
|
CStopWatch();
|
||||||
~CStopWatch();
|
~CStopWatch();
|
||||||
|
|
||||||
unsigned long start();
|
unsigned long long time() const;
|
||||||
unsigned int elapsed();
|
|
||||||
|
unsigned long long start();
|
||||||
|
unsigned int elapsed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
LARGE_INTEGER m_frequency;
|
LARGE_INTEGER m_frequencyS;
|
||||||
|
LARGE_INTEGER m_frequencyMS;
|
||||||
LARGE_INTEGER m_start;
|
LARGE_INTEGER m_start;
|
||||||
#else
|
#else
|
||||||
struct timeval m_start;
|
unsigned long long m_startMS;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2018 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -21,21 +21,32 @@
|
|||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
|
||||||
CStopWatch::CStopWatch() :
|
CStopWatch::CStopWatch() :
|
||||||
m_frequency(),
|
m_frequencyS(),
|
||||||
|
m_frequencyMS(),
|
||||||
m_start()
|
m_start()
|
||||||
{
|
{
|
||||||
::QueryPerformanceFrequency(&m_frequency);
|
::QueryPerformanceFrequency(&m_frequencyS);
|
||||||
|
|
||||||
|
m_frequencyMS.QuadPart = m_frequencyS.QuadPart / 1000ULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CStopWatch::~CStopWatch()
|
CStopWatch::~CStopWatch()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long CStopWatch::start()
|
unsigned long long CStopWatch::time() const
|
||||||
|
{
|
||||||
|
LARGE_INTEGER now;
|
||||||
|
::QueryPerformanceCounter(&now);
|
||||||
|
|
||||||
|
return (unsigned long long)(now.QuadPart / m_frequencyMS.QuadPart);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long long CStopWatch::start()
|
||||||
{
|
{
|
||||||
::QueryPerformanceCounter(&m_start);
|
::QueryPerformanceCounter(&m_start);
|
||||||
|
|
||||||
return (unsigned long)(m_start.QuadPart / m_frequency.QuadPart);
|
return (unsigned long long)(m_start.QuadPart / m_frequencyS.QuadPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int CStopWatch::elapsed()
|
unsigned int CStopWatch::elapsed()
|
||||||
@ -46,15 +57,16 @@ unsigned int CStopWatch::elapsed()
|
|||||||
LARGE_INTEGER temp;
|
LARGE_INTEGER temp;
|
||||||
temp.QuadPart = (now.QuadPart - m_start.QuadPart) * 1000;
|
temp.QuadPart = (now.QuadPart - m_start.QuadPart) * 1000;
|
||||||
|
|
||||||
return (unsigned int)(temp.QuadPart / m_frequency.QuadPart);
|
return (unsigned int)(temp.QuadPart / m_frequencyS.QuadPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
CStopWatch::CStopWatch() :
|
CStopWatch::CStopWatch() :
|
||||||
m_start()
|
m_startMS(0ULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,23 +74,32 @@ CStopWatch::~CStopWatch()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long CStopWatch::start()
|
unsigned long long CStopWatch::time() const
|
||||||
{
|
|
||||||
::gettimeofday(&m_start, NULL);
|
|
||||||
|
|
||||||
return m_start.tv_usec;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int CStopWatch::elapsed()
|
|
||||||
{
|
{
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
::gettimeofday(&now, NULL);
|
::gettimeofday(&now, NULL);
|
||||||
|
|
||||||
unsigned int elapsed = (now.tv_sec - m_start.tv_sec) * 1000U;
|
return now.tv_sec * 1000ULL + now.tv_usec / 1000ULL;
|
||||||
elapsed += now.tv_usec / 1000U;
|
}
|
||||||
elapsed -= m_start.tv_usec / 1000U;
|
|
||||||
|
|
||||||
return elapsed;
|
unsigned long long CStopWatch::start()
|
||||||
|
{
|
||||||
|
struct timespec now;
|
||||||
|
::clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
|
m_startMS = now.tv_sec * 1000ULL + now.tv_nsec / 1000000ULL;
|
||||||
|
|
||||||
|
return m_startMS;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CStopWatch::elapsed()
|
||||||
|
{
|
||||||
|
struct timespec now;
|
||||||
|
::clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
|
unsigned long long nowMS = now.tv_sec * 1000ULL + now.tv_nsec / 1000000ULL;
|
||||||
|
|
||||||
|
return nowMS - m_startMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2018 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -31,15 +31,18 @@ public:
|
|||||||
CStopWatch();
|
CStopWatch();
|
||||||
~CStopWatch();
|
~CStopWatch();
|
||||||
|
|
||||||
unsigned long start();
|
unsigned long long time() const;
|
||||||
unsigned int elapsed();
|
|
||||||
|
unsigned long long start();
|
||||||
|
unsigned int elapsed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
LARGE_INTEGER m_frequency;
|
LARGE_INTEGER m_frequencyS;
|
||||||
|
LARGE_INTEGER m_frequencyMS;
|
||||||
LARGE_INTEGER m_start;
|
LARGE_INTEGER m_start;
|
||||||
#else
|
#else
|
||||||
struct timeval m_start;
|
unsigned long long m_startMS;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2018 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -21,21 +21,32 @@
|
|||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
|
||||||
CStopWatch::CStopWatch() :
|
CStopWatch::CStopWatch() :
|
||||||
m_frequency(),
|
m_frequencyS(),
|
||||||
|
m_frequencyMS(),
|
||||||
m_start()
|
m_start()
|
||||||
{
|
{
|
||||||
::QueryPerformanceFrequency(&m_frequency);
|
::QueryPerformanceFrequency(&m_frequencyS);
|
||||||
|
|
||||||
|
m_frequencyMS.QuadPart = m_frequencyS.QuadPart / 1000ULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CStopWatch::~CStopWatch()
|
CStopWatch::~CStopWatch()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long CStopWatch::start()
|
unsigned long long CStopWatch::time() const
|
||||||
|
{
|
||||||
|
LARGE_INTEGER now;
|
||||||
|
::QueryPerformanceCounter(&now);
|
||||||
|
|
||||||
|
return (unsigned long long)(now.QuadPart / m_frequencyMS.QuadPart);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long long CStopWatch::start()
|
||||||
{
|
{
|
||||||
::QueryPerformanceCounter(&m_start);
|
::QueryPerformanceCounter(&m_start);
|
||||||
|
|
||||||
return (unsigned long)(m_start.QuadPart / m_frequency.QuadPart);
|
return (unsigned long long)(m_start.QuadPart / m_frequencyS.QuadPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int CStopWatch::elapsed()
|
unsigned int CStopWatch::elapsed()
|
||||||
@ -46,15 +57,16 @@ unsigned int CStopWatch::elapsed()
|
|||||||
LARGE_INTEGER temp;
|
LARGE_INTEGER temp;
|
||||||
temp.QuadPart = (now.QuadPart - m_start.QuadPart) * 1000;
|
temp.QuadPart = (now.QuadPart - m_start.QuadPart) * 1000;
|
||||||
|
|
||||||
return (unsigned int)(temp.QuadPart / m_frequency.QuadPart);
|
return (unsigned int)(temp.QuadPart / m_frequencyS.QuadPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
CStopWatch::CStopWatch() :
|
CStopWatch::CStopWatch() :
|
||||||
m_start()
|
m_startMS(0ULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,23 +74,32 @@ CStopWatch::~CStopWatch()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long CStopWatch::start()
|
unsigned long long CStopWatch::time() const
|
||||||
{
|
|
||||||
::gettimeofday(&m_start, NULL);
|
|
||||||
|
|
||||||
return m_start.tv_usec;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int CStopWatch::elapsed()
|
|
||||||
{
|
{
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
::gettimeofday(&now, NULL);
|
::gettimeofday(&now, NULL);
|
||||||
|
|
||||||
unsigned int elapsed = (now.tv_sec - m_start.tv_sec) * 1000U;
|
return now.tv_sec * 1000ULL + now.tv_usec / 1000ULL;
|
||||||
elapsed += now.tv_usec / 1000U;
|
}
|
||||||
elapsed -= m_start.tv_usec / 1000U;
|
|
||||||
|
|
||||||
return elapsed;
|
unsigned long long CStopWatch::start()
|
||||||
|
{
|
||||||
|
struct timespec now;
|
||||||
|
::clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
|
m_startMS = now.tv_sec * 1000ULL + now.tv_nsec / 1000000ULL;
|
||||||
|
|
||||||
|
return m_startMS;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CStopWatch::elapsed()
|
||||||
|
{
|
||||||
|
struct timespec now;
|
||||||
|
::clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
|
unsigned long long nowMS = now.tv_sec * 1000ULL + now.tv_nsec / 1000000ULL;
|
||||||
|
|
||||||
|
return nowMS - m_startMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2018 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -31,15 +31,18 @@ public:
|
|||||||
CStopWatch();
|
CStopWatch();
|
||||||
~CStopWatch();
|
~CStopWatch();
|
||||||
|
|
||||||
unsigned long start();
|
unsigned long long time() const;
|
||||||
unsigned int elapsed();
|
|
||||||
|
unsigned long long start();
|
||||||
|
unsigned int elapsed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
LARGE_INTEGER m_frequency;
|
LARGE_INTEGER m_frequencyS;
|
||||||
|
LARGE_INTEGER m_frequencyMS;
|
||||||
LARGE_INTEGER m_start;
|
LARGE_INTEGER m_start;
|
||||||
#else
|
#else
|
||||||
struct timeval m_start;
|
unsigned long long m_startMS;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2018 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -21,21 +21,32 @@
|
|||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
|
||||||
CStopWatch::CStopWatch() :
|
CStopWatch::CStopWatch() :
|
||||||
m_frequency(),
|
m_frequencyS(),
|
||||||
|
m_frequencyMS(),
|
||||||
m_start()
|
m_start()
|
||||||
{
|
{
|
||||||
::QueryPerformanceFrequency(&m_frequency);
|
::QueryPerformanceFrequency(&m_frequencyS);
|
||||||
|
|
||||||
|
m_frequencyMS.QuadPart = m_frequencyS.QuadPart / 1000ULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CStopWatch::~CStopWatch()
|
CStopWatch::~CStopWatch()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long CStopWatch::start()
|
unsigned long long CStopWatch::time() const
|
||||||
|
{
|
||||||
|
LARGE_INTEGER now;
|
||||||
|
::QueryPerformanceCounter(&now);
|
||||||
|
|
||||||
|
return (unsigned long long)(now.QuadPart / m_frequencyMS.QuadPart);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long long CStopWatch::start()
|
||||||
{
|
{
|
||||||
::QueryPerformanceCounter(&m_start);
|
::QueryPerformanceCounter(&m_start);
|
||||||
|
|
||||||
return (unsigned long)(m_start.QuadPart / m_frequency.QuadPart);
|
return (unsigned long long)(m_start.QuadPart / m_frequencyS.QuadPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int CStopWatch::elapsed()
|
unsigned int CStopWatch::elapsed()
|
||||||
@ -46,15 +57,16 @@ unsigned int CStopWatch::elapsed()
|
|||||||
LARGE_INTEGER temp;
|
LARGE_INTEGER temp;
|
||||||
temp.QuadPart = (now.QuadPart - m_start.QuadPart) * 1000;
|
temp.QuadPart = (now.QuadPart - m_start.QuadPart) * 1000;
|
||||||
|
|
||||||
return (unsigned int)(temp.QuadPart / m_frequency.QuadPart);
|
return (unsigned int)(temp.QuadPart / m_frequencyS.QuadPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
CStopWatch::CStopWatch() :
|
CStopWatch::CStopWatch() :
|
||||||
m_start()
|
m_startMS(0ULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,23 +74,32 @@ CStopWatch::~CStopWatch()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long CStopWatch::start()
|
unsigned long long CStopWatch::time() const
|
||||||
{
|
|
||||||
::gettimeofday(&m_start, NULL);
|
|
||||||
|
|
||||||
return m_start.tv_usec;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int CStopWatch::elapsed()
|
|
||||||
{
|
{
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
::gettimeofday(&now, NULL);
|
::gettimeofday(&now, NULL);
|
||||||
|
|
||||||
unsigned int elapsed = (now.tv_sec - m_start.tv_sec) * 1000U;
|
return now.tv_sec * 1000ULL + now.tv_usec / 1000ULL;
|
||||||
elapsed += now.tv_usec / 1000U;
|
}
|
||||||
elapsed -= m_start.tv_usec / 1000U;
|
|
||||||
|
|
||||||
return elapsed;
|
unsigned long long CStopWatch::start()
|
||||||
|
{
|
||||||
|
struct timespec now;
|
||||||
|
::clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
|
m_startMS = now.tv_sec * 1000ULL + now.tv_nsec / 1000000ULL;
|
||||||
|
|
||||||
|
return m_startMS;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CStopWatch::elapsed()
|
||||||
|
{
|
||||||
|
struct timespec now;
|
||||||
|
::clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
|
unsigned long long nowMS = now.tv_sec * 1000ULL + now.tv_nsec / 1000000ULL;
|
||||||
|
|
||||||
|
return nowMS - m_startMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2018 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -31,15 +31,18 @@ public:
|
|||||||
CStopWatch();
|
CStopWatch();
|
||||||
~CStopWatch();
|
~CStopWatch();
|
||||||
|
|
||||||
unsigned long start();
|
unsigned long long time() const;
|
||||||
unsigned int elapsed();
|
|
||||||
|
unsigned long long start();
|
||||||
|
unsigned int elapsed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
LARGE_INTEGER m_frequency;
|
LARGE_INTEGER m_frequencyS;
|
||||||
|
LARGE_INTEGER m_frequencyMS;
|
||||||
LARGE_INTEGER m_start;
|
LARGE_INTEGER m_start;
|
||||||
#else
|
#else
|
||||||
struct timeval m_start;
|
unsigned long long m_startMS;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2018 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -21,21 +21,32 @@
|
|||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
|
||||||
CStopWatch::CStopWatch() :
|
CStopWatch::CStopWatch() :
|
||||||
m_frequency(),
|
m_frequencyS(),
|
||||||
|
m_frequencyMS(),
|
||||||
m_start()
|
m_start()
|
||||||
{
|
{
|
||||||
::QueryPerformanceFrequency(&m_frequency);
|
::QueryPerformanceFrequency(&m_frequencyS);
|
||||||
|
|
||||||
|
m_frequencyMS.QuadPart = m_frequencyS.QuadPart / 1000ULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CStopWatch::~CStopWatch()
|
CStopWatch::~CStopWatch()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long CStopWatch::start()
|
unsigned long long CStopWatch::time() const
|
||||||
|
{
|
||||||
|
LARGE_INTEGER now;
|
||||||
|
::QueryPerformanceCounter(&now);
|
||||||
|
|
||||||
|
return (unsigned long long)(now.QuadPart / m_frequencyMS.QuadPart);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long long CStopWatch::start()
|
||||||
{
|
{
|
||||||
::QueryPerformanceCounter(&m_start);
|
::QueryPerformanceCounter(&m_start);
|
||||||
|
|
||||||
return (unsigned long)(m_start.QuadPart / m_frequency.QuadPart);
|
return (unsigned long long)(m_start.QuadPart / m_frequencyS.QuadPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int CStopWatch::elapsed()
|
unsigned int CStopWatch::elapsed()
|
||||||
@ -46,15 +57,16 @@ unsigned int CStopWatch::elapsed()
|
|||||||
LARGE_INTEGER temp;
|
LARGE_INTEGER temp;
|
||||||
temp.QuadPart = (now.QuadPart - m_start.QuadPart) * 1000;
|
temp.QuadPart = (now.QuadPart - m_start.QuadPart) * 1000;
|
||||||
|
|
||||||
return (unsigned int)(temp.QuadPart / m_frequency.QuadPart);
|
return (unsigned int)(temp.QuadPart / m_frequencyS.QuadPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
CStopWatch::CStopWatch() :
|
CStopWatch::CStopWatch() :
|
||||||
m_start()
|
m_startMS(0ULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,23 +74,32 @@ CStopWatch::~CStopWatch()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long CStopWatch::start()
|
unsigned long long CStopWatch::time() const
|
||||||
{
|
|
||||||
::gettimeofday(&m_start, NULL);
|
|
||||||
|
|
||||||
return m_start.tv_usec;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int CStopWatch::elapsed()
|
|
||||||
{
|
{
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
::gettimeofday(&now, NULL);
|
::gettimeofday(&now, NULL);
|
||||||
|
|
||||||
unsigned int elapsed = (now.tv_sec - m_start.tv_sec) * 1000U;
|
return now.tv_sec * 1000ULL + now.tv_usec / 1000ULL;
|
||||||
elapsed += now.tv_usec / 1000U;
|
}
|
||||||
elapsed -= m_start.tv_usec / 1000U;
|
|
||||||
|
|
||||||
return elapsed;
|
unsigned long long CStopWatch::start()
|
||||||
|
{
|
||||||
|
struct timespec now;
|
||||||
|
::clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
|
m_startMS = now.tv_sec * 1000ULL + now.tv_nsec / 1000000ULL;
|
||||||
|
|
||||||
|
return m_startMS;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CStopWatch::elapsed()
|
||||||
|
{
|
||||||
|
struct timespec now;
|
||||||
|
::clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
|
unsigned long long nowMS = now.tv_sec * 1000ULL + now.tv_nsec / 1000000ULL;
|
||||||
|
|
||||||
|
return nowMS - m_startMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2018 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -31,15 +31,18 @@ public:
|
|||||||
CStopWatch();
|
CStopWatch();
|
||||||
~CStopWatch();
|
~CStopWatch();
|
||||||
|
|
||||||
unsigned long start();
|
unsigned long long time() const;
|
||||||
unsigned int elapsed();
|
|
||||||
|
unsigned long long start();
|
||||||
|
unsigned int elapsed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
LARGE_INTEGER m_frequency;
|
LARGE_INTEGER m_frequencyS;
|
||||||
|
LARGE_INTEGER m_frequencyMS;
|
||||||
LARGE_INTEGER m_start;
|
LARGE_INTEGER m_start;
|
||||||
#else
|
#else
|
||||||
struct timeval m_start;
|
unsigned long long m_startMS;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2018 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -21,21 +21,32 @@
|
|||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
|
||||||
CStopWatch::CStopWatch() :
|
CStopWatch::CStopWatch() :
|
||||||
m_frequency(),
|
m_frequencyS(),
|
||||||
|
m_frequencyMS(),
|
||||||
m_start()
|
m_start()
|
||||||
{
|
{
|
||||||
::QueryPerformanceFrequency(&m_frequency);
|
::QueryPerformanceFrequency(&m_frequencyS);
|
||||||
|
|
||||||
|
m_frequencyMS.QuadPart = m_frequencyS.QuadPart / 1000ULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CStopWatch::~CStopWatch()
|
CStopWatch::~CStopWatch()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long CStopWatch::start()
|
unsigned long long CStopWatch::time() const
|
||||||
|
{
|
||||||
|
LARGE_INTEGER now;
|
||||||
|
::QueryPerformanceCounter(&now);
|
||||||
|
|
||||||
|
return (unsigned long long)(now.QuadPart / m_frequencyMS.QuadPart);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long long CStopWatch::start()
|
||||||
{
|
{
|
||||||
::QueryPerformanceCounter(&m_start);
|
::QueryPerformanceCounter(&m_start);
|
||||||
|
|
||||||
return (unsigned long)(m_start.QuadPart / m_frequency.QuadPart);
|
return (unsigned long long)(m_start.QuadPart / m_frequencyS.QuadPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int CStopWatch::elapsed()
|
unsigned int CStopWatch::elapsed()
|
||||||
@ -46,15 +57,16 @@ unsigned int CStopWatch::elapsed()
|
|||||||
LARGE_INTEGER temp;
|
LARGE_INTEGER temp;
|
||||||
temp.QuadPart = (now.QuadPart - m_start.QuadPart) * 1000;
|
temp.QuadPart = (now.QuadPart - m_start.QuadPart) * 1000;
|
||||||
|
|
||||||
return (unsigned int)(temp.QuadPart / m_frequency.QuadPart);
|
return (unsigned int)(temp.QuadPart / m_frequencyS.QuadPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
CStopWatch::CStopWatch() :
|
CStopWatch::CStopWatch() :
|
||||||
m_start()
|
m_startMS(0ULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,23 +74,32 @@ CStopWatch::~CStopWatch()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long CStopWatch::start()
|
unsigned long long CStopWatch::time() const
|
||||||
{
|
|
||||||
::gettimeofday(&m_start, NULL);
|
|
||||||
|
|
||||||
return m_start.tv_usec;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int CStopWatch::elapsed()
|
|
||||||
{
|
{
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
::gettimeofday(&now, NULL);
|
::gettimeofday(&now, NULL);
|
||||||
|
|
||||||
unsigned int elapsed = (now.tv_sec - m_start.tv_sec) * 1000U;
|
return now.tv_sec * 1000ULL + now.tv_usec / 1000ULL;
|
||||||
elapsed += now.tv_usec / 1000U;
|
}
|
||||||
elapsed -= m_start.tv_usec / 1000U;
|
|
||||||
|
|
||||||
return elapsed;
|
unsigned long long CStopWatch::start()
|
||||||
|
{
|
||||||
|
struct timespec now;
|
||||||
|
::clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
|
m_startMS = now.tv_sec * 1000ULL + now.tv_nsec / 1000000ULL;
|
||||||
|
|
||||||
|
return m_startMS;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CStopWatch::elapsed()
|
||||||
|
{
|
||||||
|
struct timespec now;
|
||||||
|
::clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
|
unsigned long long nowMS = now.tv_sec * 1000ULL + now.tv_nsec / 1000000ULL;
|
||||||
|
|
||||||
|
return nowMS - m_startMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
|
* Copyright (C) 2015,2016,2018 by Jonathan Naylor G4KLX
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -31,15 +31,18 @@ public:
|
|||||||
CStopWatch();
|
CStopWatch();
|
||||||
~CStopWatch();
|
~CStopWatch();
|
||||||
|
|
||||||
unsigned long start();
|
unsigned long long time() const;
|
||||||
unsigned int elapsed();
|
|
||||||
|
unsigned long long start();
|
||||||
|
unsigned int elapsed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
LARGE_INTEGER m_frequency;
|
LARGE_INTEGER m_frequencyS;
|
||||||
|
LARGE_INTEGER m_frequencyMS;
|
||||||
LARGE_INTEGER m_start;
|
LARGE_INTEGER m_start;
|
||||||
#else
|
#else
|
||||||
struct timeval m_start;
|
unsigned long long m_startMS;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user