mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Refactor startup timing a little by getting the current time the moment the application enters its main function, then passing that to Application's constructor. Also fix the titlebar bug by setting the title bar at the end of initializeGL() instead of at the end of the first frame (which would actually further the inaccuracy of the startup time).
This commit is contained in:
parent
a8c4e928b8
commit
fb553fce80
3 changed files with 43 additions and 41 deletions
|
@ -114,7 +114,7 @@ void GLCanvas::wheelEvent(QWheelEvent* event) {
|
|||
Application::getInstance()->wheelEvent(event);
|
||||
}
|
||||
|
||||
Application::Application(int& argc, char** argv) :
|
||||
Application::Application(int& argc, char** argv, timeval &startup_time) :
|
||||
QApplication(argc, argv),
|
||||
_window(new QMainWindow(desktop())),
|
||||
_glWidget(new GLCanvas()),
|
||||
|
@ -152,7 +152,7 @@ Application::Application(int& argc, char** argv) :
|
|||
_bytesPerSecond(0),
|
||||
_bytesCount(0)
|
||||
{
|
||||
gettimeofday(&_applicationStartupTime, NULL);
|
||||
_applicationStartupTime = startup_time;
|
||||
_window->setWindowTitle("Interface");
|
||||
printLog("Interface Startup:\n");
|
||||
|
||||
|
@ -268,6 +268,15 @@ void Application::initializeGL() {
|
|||
QTimer* idleTimer = new QTimer(this);
|
||||
connect(idleTimer, SIGNAL(timeout()), SLOT(idle()));
|
||||
idleTimer->start(0);
|
||||
|
||||
if (_justStarted) {
|
||||
float startupTime = (usecTimestampNow() - usecTimestamp(&_applicationStartupTime))/1000000.0;
|
||||
_justStarted = false;
|
||||
char title[50];
|
||||
sprintf(title, "Interface: %4.2f seconds\n", startupTime);
|
||||
printLog("%s", title);
|
||||
_window->setWindowTitle(title);
|
||||
}
|
||||
}
|
||||
|
||||
void Application::paintGL() {
|
||||
|
@ -403,16 +412,6 @@ void Application::paintGL() {
|
|||
|
||||
|
||||
_frameCount++;
|
||||
|
||||
// If application has just started, report time from startup to now (first frame display)
|
||||
if (_justStarted) {
|
||||
float startupTime = (usecTimestampNow() - usecTimestamp(&_applicationStartupTime))/1000000.0;
|
||||
_justStarted = false;
|
||||
char title[50];
|
||||
sprintf(title, "Interface: %4.2f seconds\n", startupTime);
|
||||
printLog("%s", title);
|
||||
_window->setWindowTitle(title);
|
||||
}
|
||||
}
|
||||
|
||||
void Application::resizeGL(int width, int height) {
|
||||
|
|
|
@ -46,7 +46,7 @@ class Application : public QApplication {
|
|||
public:
|
||||
static Application* getInstance() { return static_cast<Application*>(QCoreApplication::instance()); }
|
||||
|
||||
Application(int& argc, char** argv);
|
||||
Application(int& argc, char** argv, timeval &startup_time);
|
||||
|
||||
void initializeGL();
|
||||
void paintGL();
|
||||
|
|
|
@ -20,7 +20,10 @@
|
|||
|
||||
int main(int argc, const char * argv[]) {
|
||||
|
||||
Application app(argc, const_cast<char**>(argv));
|
||||
timeval startup_time;
|
||||
gettimeofday(&startup_time, NULL);
|
||||
|
||||
Application app(argc, const_cast<char**>(argv), startup_time);
|
||||
printLog( "Created QT Application.\n" );
|
||||
int exitCode = app.exec();
|
||||
printLog("Normal exit.\n");
|
||||
|
|
Loading…
Reference in a new issue