Josh Posted August 25, 2024 Posted August 25, 2024 This is what I use for some internal timing stuff: #ifdef _WIN32 double PCFreq = 0.0; __int64 CounterStart = 0; bool counterstarted = false; #endif double fMillisecs() { #ifdef _WIN32 //return GetTickCount64(); // this only updates every 16 milliseconds, don't use it! //return timeGetTime(); if (!counterstarted) { LARGE_INTEGER li; QueryPerformanceFrequency(&li); PCFreq = double(li.QuadPart) / 1000.0; QueryPerformanceCounter(&li); CounterStart = li.QuadPart; counterstarted = true; } LARGE_INTEGER li; QueryPerformanceCounter(&li); //return (((double(li.QuadPart - CounterStart) / PCFreq) * 1000.0)) / 1000.0; return double(li.QuadPart - CounterStart) / PCFreq; #else long t; struct timeval tv; gettimeofday(&tv, 0); long secstomillisecs = 1000; t = tv.tv_sec * secstomillisecs; t += tv.tv_usec / 1000.0; return t; #endif } 1 Quote Let's build cool stuff and have fun.
Dreikblack Posted August 25, 2024 Posted August 25, 2024 Thats what Canardia uses, but i was not sure if it's fine to use for not profiling purposes but i see it is now. His code: // Stopwatch.h #pragma once class Stopwatch { public: LARGE_INTEGER StartTime, Frequency, StopTime, ElapsedTime; Stopwatch(); void Start(); double Elapsed(); }; // Stopwatch.cpp #include "UltraEngine.h" #include "Stopwatch.h" Stopwatch::Stopwatch() { QueryPerformanceFrequency(&Frequency); } void Stopwatch::Start() { QueryPerformanceCounter(&StartTime); } double Stopwatch::Elapsed() { QueryPerformanceCounter(&StopTime); ElapsedTime.QuadPart = StopTime.QuadPart - StartTime.QuadPart; return (double)(ElapsedTime.QuadPart) / (Frequency.QuadPart); } Quote Check out Slipgate Tactics demo, which is made with Ultra Engine/Leadwerks 5: https://www.leadwerks.com/community/topic/61480-slipgate-tactics-demo/
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.