mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 13:07:04 +02:00
More gettimeofday cleanup
This commit is contained in:
parent
ab76e6a00c
commit
f7f30e118c
14 changed files with 57 additions and 168 deletions
|
@ -134,7 +134,7 @@ QString& Application::resourcesPath() {
|
||||||
return staticResourcePath;
|
return staticResourcePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::Application(int& argc, char** argv, timeval &startup_time) :
|
Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
QApplication(argc, argv),
|
QApplication(argc, argv),
|
||||||
_window(new QMainWindow(desktop())),
|
_window(new QMainWindow(desktop())),
|
||||||
_glWidget(new GLCanvas()),
|
_glWidget(new GLCanvas()),
|
||||||
|
@ -507,7 +507,7 @@ void Application::initializeGL() {
|
||||||
_idleLoopStdev.reset();
|
_idleLoopStdev.reset();
|
||||||
|
|
||||||
if (_justStarted) {
|
if (_justStarted) {
|
||||||
float startupTime = (usecTimestampNow() - usecTimestamp(&_applicationStartupTime)) / 1000000.0;
|
float startupTime = _applicationStartupTime.elapsed() / 1000.0;
|
||||||
_justStarted = false;
|
_justStarted = false;
|
||||||
qDebug("Startup time: %4.2f seconds.", startupTime);
|
qDebug("Startup time: %4.2f seconds.", startupTime);
|
||||||
const char LOGSTASH_INTERFACE_START_TIME_KEY[] = "interface-start-time";
|
const char LOGSTASH_INTERFACE_START_TIME_KEY[] = "interface-start-time";
|
||||||
|
@ -1273,21 +1273,21 @@ void Application::sendPingPackets() {
|
||||||
|
|
||||||
// Every second, check the frame rates and other stuff
|
// Every second, check the frame rates and other stuff
|
||||||
void Application::timer() {
|
void Application::timer() {
|
||||||
gettimeofday(&_timerEnd, NULL);
|
|
||||||
|
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) {
|
||||||
sendPingPackets();
|
sendPingPackets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float diffTime = (float)_timerStart.nsecsElapsed() / 1000000000.0;
|
||||||
|
|
||||||
_fps = (float)_frameCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
|
_fps = (float)_frameCount / diffTime;
|
||||||
|
|
||||||
_packetsPerSecond = (float) _datagramProcessor.getPacketCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
|
_packetsPerSecond = (float) _datagramProcessor.getPacketCount() / diffTime;
|
||||||
_bytesPerSecond = (float) _datagramProcessor.getByteCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
|
_bytesPerSecond = (float) _datagramProcessor.getByteCount() / diffTime;
|
||||||
_frameCount = 0;
|
_frameCount = 0;
|
||||||
|
|
||||||
_datagramProcessor.resetCounters();
|
_datagramProcessor.resetCounters();
|
||||||
|
|
||||||
gettimeofday(&_timerStart, NULL);
|
_timerStart.start();
|
||||||
|
|
||||||
// ask the node list to check in with the domain server
|
// ask the node list to check in with the domain server
|
||||||
NodeList::getInstance()->sendDomainServerCheckIn();
|
NodeList::getInstance()->sendDomainServerCheckIn();
|
||||||
|
@ -1300,13 +1300,11 @@ void Application::idle() {
|
||||||
bool showWarnings = getLogger()->extraDebugging();
|
bool showWarnings = getLogger()->extraDebugging();
|
||||||
PerformanceWarning warn(showWarnings, "Application::idle()");
|
PerformanceWarning warn(showWarnings, "Application::idle()");
|
||||||
|
|
||||||
timeval check;
|
|
||||||
gettimeofday(&check, NULL);
|
|
||||||
|
|
||||||
// Only run simulation code if more than IDLE_SIMULATE_MSECS have passed since last time we ran
|
// Only run simulation code if more than IDLE_SIMULATE_MSECS have passed since last time we ran
|
||||||
|
|
||||||
double timeSinceLastUpdate = diffclock(&_lastTimeUpdated, &check);
|
double timeSinceLastUpdate = (double)_lastTimeUpdated.nsecsElapsed() / 1000000.0;
|
||||||
if (timeSinceLastUpdate > IDLE_SIMULATE_MSECS) {
|
if (timeSinceLastUpdate > IDLE_SIMULATE_MSECS) {
|
||||||
|
_lastTimeUpdated.start();
|
||||||
{
|
{
|
||||||
PerformanceWarning warn(showWarnings, "Application::idle()... update()");
|
PerformanceWarning warn(showWarnings, "Application::idle()... update()");
|
||||||
const float BIGGEST_DELTA_TIME_SECS = 0.25f;
|
const float BIGGEST_DELTA_TIME_SECS = 0.25f;
|
||||||
|
@ -1318,7 +1316,6 @@ void Application::idle() {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
PerformanceWarning warn(showWarnings, "Application::idle()... rest of it");
|
PerformanceWarning warn(showWarnings, "Application::idle()... rest of it");
|
||||||
_lastTimeUpdated = check;
|
|
||||||
_idleLoopStdev.addValue(timeSinceLastUpdate);
|
_idleLoopStdev.addValue(timeSinceLastUpdate);
|
||||||
|
|
||||||
// Record standard deviation and reset counter if needed
|
// Record standard deviation and reset counter if needed
|
||||||
|
@ -1634,8 +1631,8 @@ void Application::init() {
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
gettimeofday(&_timerStart, NULL);
|
_timerStart.start();
|
||||||
gettimeofday(&_lastTimeUpdated, NULL);
|
_lastTimeUpdated.start();
|
||||||
|
|
||||||
Menu::getInstance()->loadSettings();
|
Menu::getInstance()->loadSettings();
|
||||||
if (Menu::getInstance()->getAudioJitterBufferSamples() != 0) {
|
if (Menu::getInstance()->getAudioJitterBufferSamples() != 0) {
|
||||||
|
|
|
@ -117,7 +117,7 @@ public:
|
||||||
static Application* getInstance() { return static_cast<Application*>(QCoreApplication::instance()); }
|
static Application* getInstance() { return static_cast<Application*>(QCoreApplication::instance()); }
|
||||||
static QString& resourcesPath();
|
static QString& resourcesPath();
|
||||||
|
|
||||||
Application(int& argc, char** argv, timeval &startup_time);
|
Application(int& argc, char** argv, QElapsedTimer &startup_time);
|
||||||
~Application();
|
~Application();
|
||||||
|
|
||||||
void restoreSizeAndPosition();
|
void restoreSizeAndPosition();
|
||||||
|
@ -391,9 +391,9 @@ private:
|
||||||
|
|
||||||
int _frameCount;
|
int _frameCount;
|
||||||
float _fps;
|
float _fps;
|
||||||
timeval _applicationStartupTime;
|
QElapsedTimer _applicationStartupTime;
|
||||||
timeval _timerStart, _timerEnd;
|
QElapsedTimer _timerStart;
|
||||||
timeval _lastTimeUpdated;
|
QElapsedTimer _lastTimeUpdated;
|
||||||
bool _justStarted;
|
bool _justStarted;
|
||||||
Stars _stars;
|
Stars _stars;
|
||||||
|
|
||||||
|
|
|
@ -172,14 +172,6 @@ void renderWorldBox() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double diffclock(timeval *clock1,timeval *clock2)
|
|
||||||
{
|
|
||||||
double diffms = (clock2->tv_sec - clock1->tv_sec) * 1000.0;
|
|
||||||
diffms += (clock2->tv_usec - clock1->tv_usec) / 1000.0; // us to ms
|
|
||||||
|
|
||||||
return diffms;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return a random vector of average length 1
|
// Return a random vector of average length 1
|
||||||
const glm::vec3 randVector() {
|
const glm::vec3 randVector() {
|
||||||
return glm::vec3(randFloat() - 0.5f, randFloat() - 0.5f, randFloat() - 0.5f) * 2.f;
|
return glm::vec3(randFloat() - 0.5f, randFloat() - 0.5f, randFloat() - 0.5f) * 2.f;
|
||||||
|
@ -411,68 +403,61 @@ void runTimingTests() {
|
||||||
int iResults[numTests];
|
int iResults[numTests];
|
||||||
float fTest = 1.0;
|
float fTest = 1.0;
|
||||||
float fResults[numTests];
|
float fResults[numTests];
|
||||||
timeval startTime, endTime;
|
QElapsedTimer startTime;
|
||||||
|
startTime.start();
|
||||||
float elapsedMsecs;
|
float elapsedMsecs;
|
||||||
gettimeofday(&startTime, NULL);
|
|
||||||
for (int i = 1; i < numTests; i++) {
|
elapsedMsecs = (float)startTime.nsecsElapsed() / 1000.0;
|
||||||
gettimeofday(&endTime, NULL);
|
qDebug("QElapsedTimer::nsecElapsed() usecs: %f", 1000.0f * elapsedMsecs / (float) numTests);
|
||||||
}
|
|
||||||
elapsedMsecs = diffclock(&startTime, &endTime);
|
|
||||||
qDebug("gettimeofday() usecs: %f", 1000.0f * elapsedMsecs / (float) numTests);
|
|
||||||
|
|
||||||
// Random number generation
|
// Random number generation
|
||||||
gettimeofday(&startTime, NULL);
|
startTime.start();
|
||||||
for (int i = 1; i < numTests; i++) {
|
for (int i = 1; i < numTests; i++) {
|
||||||
iResults[i] = rand();
|
iResults[i] = rand();
|
||||||
}
|
}
|
||||||
gettimeofday(&endTime, NULL);
|
elapsedMsecs = (float)startTime.nsecsElapsed() / 1000.0;
|
||||||
elapsedMsecs = diffclock(&startTime, &endTime);
|
|
||||||
qDebug("rand() stored in array usecs: %f, first result:%d", 1000.0f * elapsedMsecs / (float) numTests, iResults[0]);
|
qDebug("rand() stored in array usecs: %f, first result:%d", 1000.0f * elapsedMsecs / (float) numTests, iResults[0]);
|
||||||
|
|
||||||
// Random number generation using randFloat()
|
// Random number generation using randFloat()
|
||||||
gettimeofday(&startTime, NULL);
|
startTime.start();
|
||||||
for (int i = 1; i < numTests; i++) {
|
for (int i = 1; i < numTests; i++) {
|
||||||
fResults[i] = randFloat();
|
fResults[i] = randFloat();
|
||||||
}
|
}
|
||||||
gettimeofday(&endTime, NULL);
|
elapsedMsecs = (float)startTime.nsecsElapsed() / 1000.0;
|
||||||
elapsedMsecs = diffclock(&startTime, &endTime);
|
|
||||||
qDebug("randFloat() stored in array usecs: %f, first result: %f", 1000.0f * elapsedMsecs / (float) numTests, fResults[0]);
|
qDebug("randFloat() stored in array usecs: %f, first result: %f", 1000.0f * elapsedMsecs / (float) numTests, fResults[0]);
|
||||||
|
|
||||||
// PowF function
|
// PowF function
|
||||||
fTest = 1145323.2342f;
|
fTest = 1145323.2342f;
|
||||||
gettimeofday(&startTime, NULL);
|
startTime.start();
|
||||||
for (int i = 1; i < numTests; i++) {
|
for (int i = 1; i < numTests; i++) {
|
||||||
fTest = powf(fTest, 0.5f);
|
fTest = powf(fTest, 0.5f);
|
||||||
}
|
}
|
||||||
gettimeofday(&endTime, NULL);
|
elapsedMsecs = (float)startTime.nsecsElapsed() / 1000.0;
|
||||||
elapsedMsecs = diffclock(&startTime, &endTime);
|
|
||||||
qDebug("powf(f, 0.5) usecs: %f", 1000.0f * elapsedMsecs / (float) numTests);
|
qDebug("powf(f, 0.5) usecs: %f", 1000.0f * elapsedMsecs / (float) numTests);
|
||||||
|
|
||||||
// Vector Math
|
// Vector Math
|
||||||
float distance;
|
float distance;
|
||||||
glm::vec3 pointA(randVector()), pointB(randVector());
|
glm::vec3 pointA(randVector()), pointB(randVector());
|
||||||
gettimeofday(&startTime, NULL);
|
startTime.start();
|
||||||
for (int i = 1; i < numTests; i++) {
|
for (int i = 1; i < numTests; i++) {
|
||||||
//glm::vec3 temp = pointA - pointB;
|
//glm::vec3 temp = pointA - pointB;
|
||||||
//float distanceSquared = glm::dot(temp, temp);
|
//float distanceSquared = glm::dot(temp, temp);
|
||||||
distance = glm::distance(pointA, pointB);
|
distance = glm::distance(pointA, pointB);
|
||||||
}
|
}
|
||||||
gettimeofday(&endTime, NULL);
|
elapsedMsecs = (float)startTime.nsecsElapsed() / 1000.0;
|
||||||
elapsedMsecs = diffclock(&startTime, &endTime);
|
|
||||||
qDebug("vector math usecs: %f [%f msecs total for %d tests], last result:%f",
|
qDebug("vector math usecs: %f [%f msecs total for %d tests], last result:%f",
|
||||||
1000.0f * elapsedMsecs / (float) numTests, elapsedMsecs, numTests, distance);
|
1000.0f * elapsedMsecs / (float) numTests, elapsedMsecs, numTests, distance);
|
||||||
|
|
||||||
// Vec3 test
|
// Vec3 test
|
||||||
glm::vec3 vecA(randVector()), vecB(randVector());
|
glm::vec3 vecA(randVector()), vecB(randVector());
|
||||||
float result;
|
float result;
|
||||||
|
|
||||||
gettimeofday(&startTime, NULL);
|
startTime.start();
|
||||||
for (int i = 1; i < numTests; i++) {
|
for (int i = 1; i < numTests; i++) {
|
||||||
glm::vec3 temp = vecA-vecB;
|
glm::vec3 temp = vecA-vecB;
|
||||||
result = glm::dot(temp,temp);
|
result = glm::dot(temp,temp);
|
||||||
}
|
}
|
||||||
gettimeofday(&endTime, NULL);
|
elapsedMsecs = (float)startTime.nsecsElapsed() / 1000.0;
|
||||||
elapsedMsecs = diffclock(&startTime, &endTime);
|
|
||||||
qDebug("vec3 assign and dot() usecs: %f, last result:%f", 1000.0f * elapsedMsecs / (float) numTests, result);
|
qDebug("vec3 assign and dot() usecs: %f, last result:%f", 1000.0f * elapsedMsecs / (float) numTests, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,6 @@ void drawVector(glm::vec3* vector);
|
||||||
|
|
||||||
void printVector(glm::vec3 vec);
|
void printVector(glm::vec3 vec);
|
||||||
|
|
||||||
double diffclock(timeval *clock1,timeval *clock2);
|
|
||||||
|
|
||||||
void renderCollisionOverlay(int width, int height, float magnitude, float red = 0, float blue = 0, float green = 0);
|
void renderCollisionOverlay(int width, int height, float magnitude, float red = 0, float blue = 0, float green = 0);
|
||||||
|
|
||||||
void renderOrientationDirections( glm::vec3 position, const glm::quat& orientation, float size );
|
void renderOrientationDirections( glm::vec3 position, const glm::quat& orientation, float size );
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
|
|
||||||
int main(int argc, const char * argv[]) {
|
int main(int argc, const char * argv[]) {
|
||||||
timeval startup_time;
|
QElapsedTimer startupTime;
|
||||||
gettimeofday(&startup_time, NULL);
|
startupTime.start();
|
||||||
|
|
||||||
// Debug option to demonstrate that the client's local time does not
|
// Debug option to demonstrate that the client's local time does not
|
||||||
// need to be in sync with any other network node. This forces clock
|
// need to be in sync with any other network node. This forces clock
|
||||||
|
@ -33,7 +33,7 @@ int main(int argc, const char * argv[]) {
|
||||||
int exitCode;
|
int exitCode;
|
||||||
{
|
{
|
||||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||||
Application app(argc, const_cast<char**>(argv), startup_time);
|
Application app(argc, const_cast<char**>(argv), startupTime);
|
||||||
|
|
||||||
QTranslator translator;
|
QTranslator translator;
|
||||||
translator.load("interface_en");
|
translator.load("interface_en");
|
||||||
|
|
|
@ -13,20 +13,22 @@
|
||||||
#include <Systime.h>
|
#include <Systime.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <QElapsedTimer>
|
||||||
|
|
||||||
#include "starfield/Controller.h"
|
#include "starfield/Controller.h"
|
||||||
|
|
||||||
using namespace starfield;
|
using namespace starfield;
|
||||||
|
|
||||||
bool Controller::computeStars(unsigned numStars, unsigned seed) {
|
bool Controller::computeStars(unsigned numStars, unsigned seed) {
|
||||||
timeval startTime;
|
QElapsedTimer startTime;
|
||||||
gettimeofday(&startTime, NULL);
|
startTime.start();
|
||||||
|
|
||||||
Generator::computeStarPositions(_inputSequence, numStars, seed);
|
Generator::computeStarPositions(_inputSequence, numStars, seed);
|
||||||
|
|
||||||
this->retile(numStars, _tileResolution);
|
this->retile(numStars, _tileResolution);
|
||||||
|
|
||||||
qDebug() << "Total time to retile and generate stars: "
|
double timeDiff = (double)startTime.nsecsElapsed() / 1000000.0; // ns to ms
|
||||||
<< ((usecTimestampNow() - usecTimestamp(&startTime)) / 1000) << "msec";
|
qDebug() << "Total time to retile and generate stars: " << timeDiff << "msec";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
#include <Systime.h>
|
#include <Systime.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <QElapsedTimer>
|
||||||
|
|
||||||
#include "starfield/Generator.h"
|
#include "starfield/Generator.h"
|
||||||
|
|
||||||
using namespace starfield;
|
using namespace starfield;
|
||||||
|
@ -24,8 +26,8 @@ void Generator::computeStarPositions(InputVertices& destination, unsigned limit,
|
||||||
InputVertices* vertices = & destination;
|
InputVertices* vertices = & destination;
|
||||||
//_limit = limit;
|
//_limit = limit;
|
||||||
|
|
||||||
timeval startTime;
|
QElapsedTimer startTime;
|
||||||
gettimeofday(&startTime, NULL);
|
startTime.start();
|
||||||
|
|
||||||
srand(seed);
|
srand(seed);
|
||||||
|
|
||||||
|
@ -70,7 +72,8 @@ void Generator::computeStarPositions(InputVertices& destination, unsigned limit,
|
||||||
vertices->push_back(InputVertex(azimuth, altitude, computeStarColor(STAR_COLORIZATION)));
|
vertices->push_back(InputVertex(azimuth, altitude, computeStarColor(STAR_COLORIZATION)));
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "Total time to generate stars: " << ((usecTimestampNow() - usecTimestamp(&startTime)) / 1000) << " msec";
|
double timeDiff = (double)startTime.nsecsElapsed() / 1000000.0; // ns to ms
|
||||||
|
qDebug() << "Total time to generate stars: " << timeDiff << " msec";
|
||||||
}
|
}
|
||||||
|
|
||||||
// computeStarColor
|
// computeStarColor
|
||||||
|
|
|
@ -62,26 +62,21 @@ BandwidthMeter::~BandwidthMeter() {
|
||||||
free(_channels);
|
free(_channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
BandwidthMeter::Stream::Stream(float msToAverage) :
|
BandwidthMeter::Stream::Stream(float msToAverage) : _value(0.0f), _msToAverage(msToAverage) {
|
||||||
_value(0.0f),
|
_prevTime.start();
|
||||||
_msToAverage(msToAverage) {
|
|
||||||
|
|
||||||
gettimeofday(& _prevTime, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BandwidthMeter::Stream::updateValue(double amount) {
|
void BandwidthMeter::Stream::updateValue(double amount) {
|
||||||
|
|
||||||
// Determine elapsed time
|
// Determine elapsed time
|
||||||
timeval now;
|
double dt = (double)_prevTime.nsecsElapsed() / 1000000.0; // ns to ms
|
||||||
gettimeofday(& now, NULL);
|
|
||||||
double dt = diffclock(& _prevTime, & now);
|
|
||||||
|
|
||||||
// Ignore this value when timer imprecision yields dt = 0
|
// Ignore this value when timer imprecision yields dt = 0
|
||||||
if (dt == 0.0) {
|
if (dt == 0.0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(& _prevTime, & now, sizeof(timeval));
|
_prevTime.start();
|
||||||
|
|
||||||
// Compute approximate average
|
// Compute approximate average
|
||||||
_value = glm::mix(_value, amount / dt,
|
_value = glm::mix(_value, amount / dt,
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
#include <Systime.h>
|
#include <Systime.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <QElapsedTimer>
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
#include "ui/TextRenderer.h"
|
#include "ui/TextRenderer.h"
|
||||||
|
@ -59,7 +61,7 @@ public:
|
||||||
private:
|
private:
|
||||||
double _value; // Current value.
|
double _value; // Current value.
|
||||||
double _msToAverage; // Milliseconds to average.
|
double _msToAverage; // Milliseconds to average.
|
||||||
timeval _prevTime; // Time of last feed.
|
QElapsedTimer _prevTime; // Time of last feed.
|
||||||
};
|
};
|
||||||
|
|
||||||
// Data model accessors
|
// Data model accessors
|
||||||
|
|
|
@ -273,8 +273,8 @@ void ScriptEngine::run() {
|
||||||
qDebug() << "Uncaught exception at line" << line << ":" << result.toString();
|
qDebug() << "Uncaught exception at line" << line << ":" << result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
timeval startTime;
|
QElapsedTimer startTime;
|
||||||
gettimeofday(&startTime, NULL);
|
startTime.start();
|
||||||
|
|
||||||
int thisFrame = 0;
|
int thisFrame = 0;
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ void ScriptEngine::run() {
|
||||||
qint64 lastUpdate = usecTimestampNow();
|
qint64 lastUpdate = usecTimestampNow();
|
||||||
|
|
||||||
while (!_isFinished) {
|
while (!_isFinished) {
|
||||||
int usecToSleep = usecTimestamp(&startTime) + (thisFrame++ * SCRIPT_DATA_CALLBACK_USECS) - usecTimestampNow();
|
int usecToSleep = (thisFrame++ * SCRIPT_DATA_CALLBACK_USECS) - startTime.nsecsElapsed() / 1000; // nsec to usec
|
||||||
if (usecToSleep > 0) {
|
if (usecToSleep > 0) {
|
||||||
usleep(usecToSleep);
|
usleep(usecToSleep);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,6 @@
|
||||||
#include "OctalCode.h"
|
#include "OctalCode.h"
|
||||||
#include "SharedUtil.h"
|
#include "SharedUtil.h"
|
||||||
|
|
||||||
quint64 usecTimestamp(const timeval *time) {
|
|
||||||
return (time->tv_sec * 1000000 + time->tv_usec);
|
|
||||||
}
|
|
||||||
|
|
||||||
int usecTimestampNowAdjust = 0;
|
int usecTimestampNowAdjust = 0;
|
||||||
void usecTimestampNowForceClockSkew(int clockSkew) {
|
void usecTimestampNowForceClockSkew(int clockSkew) {
|
||||||
::usecTimestampNowAdjust = clockSkew;
|
::usecTimestampNowAdjust = clockSkew;
|
||||||
|
|
|
@ -66,7 +66,6 @@ static const quint64 USECS_PER_SECOND = USECS_PER_MSEC * MSECS_PER_SECOND;
|
||||||
|
|
||||||
const int BITS_IN_BYTE = 8;
|
const int BITS_IN_BYTE = 8;
|
||||||
|
|
||||||
quint64 usecTimestamp(const timeval *time);
|
|
||||||
quint64 usecTimestampNow();
|
quint64 usecTimestampNow();
|
||||||
void usecTimestampNowForceClockSkew(int clockSkew);
|
void usecTimestampNowForceClockSkew(int clockSkew);
|
||||||
|
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
//
|
|
||||||
// Systime.cpp
|
|
||||||
// libraries/shared/src
|
|
||||||
//
|
|
||||||
// Copyright 2013 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
|
|
||||||
#include "Systime.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gettimeofday
|
|
||||||
* Implementation according to:
|
|
||||||
* The Open Group Base Specifications Issue 6
|
|
||||||
* IEEE Std 1003.1, 2004 Edition
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
|
||||||
*
|
|
||||||
* This source code is offered for use in the public domain. You may
|
|
||||||
* use, modify or distribute it freely.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful but
|
|
||||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
|
||||||
* DISCLAIMED. This includes but is not limited to warranties of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
* Contributed by:
|
|
||||||
* Danny Smith <dannysmith@users.sourceforge.net>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
/** Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */
|
|
||||||
#define _W32_FT_OFFSET (116444736000000000ULL)
|
|
||||||
|
|
||||||
int gettimeofday(timeval* p_tv, timezone* p_tz) {
|
|
||||||
|
|
||||||
union {
|
|
||||||
unsigned long long ns100; /**time since 1 Jan 1601 in 100ns units */
|
|
||||||
FILETIME ft;
|
|
||||||
} _now;
|
|
||||||
|
|
||||||
if (p_tv) {
|
|
||||||
GetSystemTimeAsFileTime (&_now.ft);
|
|
||||||
p_tv->tv_usec=(long)((_now.ns100 / 10ULL) % 1000000ULL );
|
|
||||||
p_tv->tv_sec= (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000ULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Always return 0 as per Open Group Base Specifications Issue 6.
|
|
||||||
Do not set errno on error. */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,27 +0,0 @@
|
||||||
//
|
|
||||||
// Systime.h
|
|
||||||
// libraries/shared/src
|
|
||||||
//
|
|
||||||
// Copyright 2013 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef hifi_Systime_h
|
|
||||||
#define hifi_Systime_h
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
|
|
||||||
#include <winsock2.h>
|
|
||||||
|
|
||||||
struct timezone {
|
|
||||||
int tz_minuteswest; /* minutes west of Greenwich */
|
|
||||||
int tz_dsttime; /* type of dst correction */
|
|
||||||
};
|
|
||||||
|
|
||||||
int gettimeofday(struct timeval* p_tv, struct timezone* p_tz);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // hifi_Systime_h
|
|
Loading…
Reference in a new issue