Skip to content

Commit

Permalink
Measure app startup time
Browse files Browse the repository at this point in the history
  • Loading branch information
mgedmin committed Sep 4, 2015
1 parent 5899d81 commit 6394ad8
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion mockup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#!/usr/bin/python
#!/usr/bin/python3
from __future__ import print_function

import time
def mark_time(what, _prev=[0]):
t = time.clock()
print("{:.3f} ({:+.3f}) {}".format(t, t-_prev[0], what))
_prev[0] = t
mark_time("in script")

import datetime
import gettext
import locale
Expand All @@ -9,16 +16,22 @@
import sys
from gettext import gettext as _

mark_time("Python imports done")


import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk, Gio, GLib, GObject

mark_time("GTK+ imports done")

pkgdir = os.path.join(os.path.dirname(__file__), 'src')
sys.path.insert(0, pkgdir)

from gtimelog.settings import Settings
from gtimelog.timelog import format_duration

mark_time("gtimelog imports done")

HELP_URL = 'https://mg.pov.lt/gtimelog'

Expand All @@ -36,6 +49,7 @@ def __init__(self):
GLib.set_prgname('gtimelog')

def do_startup(self):
mark_time("in app startup")
Gtk.Application.do_startup(self)

builder = Gtk.Builder.new_from_file(MENUS_UI_FILE)
Expand All @@ -57,6 +71,8 @@ def do_startup(self):
self.set_accels_for_action("app.quit", ["<Primary>Q"])
self.set_accels_for_action("win.send-report", ["<Primary>D"])

mark_time("app startup done")

def on_quit(self, action, parameter):
self.quit()

Expand All @@ -78,6 +94,7 @@ def on_about(self, action, parameter):
about_dialog.show()

def do_activate(self):
mark_time("in app activate")
if self.get_active_window() is not None:
self.get_active_window().present()
return
Expand All @@ -89,6 +106,10 @@ def do_activate(self):
self.add_window(window)
window.show()

GLib.idle_add(mark_time, "in main loop")

mark_time("app activate done")


class Window(Gtk.ApplicationWindow):

Expand Down Expand Up @@ -218,6 +239,7 @@ def w(self, text, tag=None):


def main():
mark_time("in main()")
# Tell GTK+ to use out translations
locale.bindtextdomain('gtimelog', LOCALE_DIR)
locale.textdomain('gtimelog')
Expand All @@ -230,6 +252,7 @@ def main():

# Run the app
app = Application()
mark_time("app created")
sys.exit(app.run(sys.argv))


Expand Down

0 comments on commit 6394ad8

Please sign in to comment.