Commits

Anonymous committed ff6cb61

Added speedtest.py to test where I can tune for speed.

Comments (0)

Files changed (1)

+#!/usr/bin/env python
+# encoding: utf-8
+
+"""Speedtest - this modules sole purpose is testing the speed of different ways to import from PyKDE4 and PyQt4.
+
+The test is inscientific (no repetitions), since I only want to get a feeling for it. 
+
+Use it via
+
+    >>> from cProfile import run;from pstats import Stats
+    >>> run("import speedtest; speedtest.initKApp()", filename="prof.prof")
+    >>> s = Stats("prof.prof")
+    >>> s.sort_stats("cum").print_stats()
+"""
+
+def kApp():
+    """Initialize a KApplication.
+
+    My profile result (as sole function): 0.316s.
+    """
+    from PyKDE4.kdeui import KApplication
+    from sys import argv
+    from PyKDE4.kdecore import KCmdLineArgs
+    return KApplication, argv, KCmdLineArgs
+
+def kdeBasicImport():
+    """Get some basic stuff I need for KDE integration.
+
+    My profile result (as sole function): 0.347s
+    First importing qt and then kde reduces the required time by half: kdeBasicImport: 0.146, qtBasicImport: 0.161
+    First importing kde, then qt reduces the time to import qt to 0, as far as profile can measure it. 
+    """
+    # Basics for KDE integration
+    from PyKDE4.kdecore import ki18n, KAboutData
+    return ki18n, KAboutData
+
+def qtBasicImport():
+    """Get some PyQt basics I need.
+
+    My profile results (as sole function): 0.144s
+    """ 
+    # basic graphical stuff
+    from PyQt4.QtGui import QWidget, QGridLayout, QCursor, QIcon, QLabel, QLineEdit
+    # basic definitions and datatypes
+    from PyQt4.QtCore import Qt, QPointF
+
+def createAboutData():
+    """Create the aboutData for PyRad."""
+    ki18n, KAboutData = kdeBasicImport()
+    appName     = "Speedtest"
+    catalog     = ""
+    programName = ki18n ("Rad")
+    version     = "0.0.1"
+    description = ki18n ("A simple radial command menu - best called with a gesture")
+    license     = KAboutData.License_GPL
+    copyright   = ki18n ("(c) 2009 Arne Babenhauserheide")
+    text        = ki18n ("pyRad is heavily inspired by Kommando, which sadly didn't make it into KDE4. Kommando in turn was inspired by the Neverwinternights menu.")
+    homePage    = "draketo.de"
+    bugEmail    = "arne_bab@web.de"
+
+    aboutData   = KAboutData (appName, catalog, programName, version, description,
+                        license, copyright, text, homePage, bugEmail)
+    return aboutData
+
+def initKApp():
+    """Initialize a basic KApplication."""
+    aboutData = createAboutData()
+    KApplication, argv, KCmdLineArgs = kApp()
+    # First we need to compile the commandline args for KDE programs
+    KCmdLineArgs.init (argv, aboutData)
+    # Then do basic initializing
+    app = KApplication()
+    # And get and show the GUI
+    return app
+