Bienvenue, Invité. Merci de vous connecter ou de vous inscrire.
Avez-vous perdu votre e-mail d'activation ?

Auteur Sujet: PYGUIML : Une GUI très lente  (Lu 1804 fois)

0 Membres et 1 Invité sur ce sujet

gaulois94

  • Sr. Member
  • ****
  • Messages: 259
    • Voir le profil
PYGUIML : Une GUI très lente
« le: Avril 05, 2012, 07:49:09 pm »
Bonjours,

voila je créé en ce moment une GUI en C++ et je commence à la porté en python (la réécris totalement). Cependant, comparé à ma GUI en C++, celle ci est extrêmement lente : elle ne dépasse pas les 20 FPS pour afficher une simple image (alors imaginé plusieurs images).

Voila le code de la GUI : http://gaulois94.rd-h.fr/Programme/PYGUIML.zip . Le code démarre de setup.py . Widgets est la classe de base pour la création de Widget. Pour le moment, je n'utilise que Widget.py, Image.py et Window.py . Ne vous occupez que des méthode update (le reste n'est pas trop importants, sauf peut être les constructeurs ;) ). Voici aussi pour vous aidez le même code (un peu près ;) ) écrit en C++ : http://gaulois94.rd-h.fr/Programme/GUIML.zip. Regardez encore une fois seulement les classes Widgets, Image et Window (je n'ai pas mis de fichier teste car c'est exactement le même que celui en python, mais écrit en C++ ;) ).

Merci d'avance :D .
« Modifié: Avril 05, 2012, 07:57:37 pm par gaulois94 »

gaulois94

  • Sr. Member
  • ****
  • Messages: 259
    • Voir le profil
Re : PYGUIML : Une GUI très lente
« Réponse #1 le: Avril 06, 2012, 06:39:42 pm »
Je précise que c'est la fonction display qui prends le plus de ressource, comme l'indique le cprofile :

         514063 function calls (512651 primitive calls) in 24.864 seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    0.000    0.000 EventManager.py:1(<module>)
      706    0.000    0.000    0.000    0.000 EventManager.py:130(_getElaspedTime)
      706    0.000    0.000    0.000    0.000 EventManager.py:139(_isResize)
      706    0.074    0.000    0.165    0.000 EventManager.py:38(update)
        1    0.000    0.000    0.000    0.000 EventManager.py:4(EventManager)
        1    0.000    0.000    0.000    0.000 EventManager.py:8(__init__)
        1    0.000    0.000    0.000    0.000 Image.py:1(<module>)
        2    0.000    0.000    0.000    0.000 Image.py:139(_getSprite)
        1    0.000    0.000    0.000    0.000 Image.py:4(Image)
     1412    0.005    0.000    0.007    0.000 Image.py:52(update)
        2    0.000    0.000    0.000    0.000 Image.py:62(_setDimensions)
        2    0.000    0.000    0.008    0.004 Image.py:7(__init__)
        1    0.000    0.000    0.000    0.000 Widget.py:1(<module>)
        2    0.000    0.000    0.000    0.000 Widget.py:31(addChild)
        2    0.000    0.000    0.000    0.000 Widget.py:44(isChild)
        1    0.000    0.000    0.000    0.000 Widget.py:5(Widget)
 2118/706    0.004    0.000    0.010    0.000 Widget.py:56(update)
        2    0.000    0.000    0.000    0.000 Widget.py:62(setRect)
        3    0.000    0.000    0.000    0.000 Widget.py:8(__init__)
        2    0.000    0.000    0.000    0.000 Widget.py:85(_setPos)
        3    0.000    0.000    0.000    0.000 Widget.py:88(_setDimensions)
        2    0.000    0.000    0.000    0.000 Widget.py:91(_setParent)
        1    0.292    0.292    0.309    0.309 Window.py:1(<module>)
        1    0.106    0.106    0.106    0.106 Window.py:10(__init__)
      706    0.013    0.000   24.257    0.034 Window.py:24(update)
      706    0.190    0.000   24.055    0.034 Window.py:48(show)
        1    0.000    0.000    0.000    0.000 Window.py:6(Window)
      706    0.002    0.000    0.002    0.000 Window.py:71(_getFramerate)
      706    0.000    0.000    0.000    0.000 Window.py:77(getEvent)
        1    0.000    0.000    0.000    0.000 __init__.py:42(normalize_encoding)
        1    0.000    0.000    0.016    0.016 __init__.py:69(search_function)                                                                                                                                                [0/744]
        1    0.000    0.000    0.000    0.000 _weakrefset.py:36(__init__)
        1    0.000    0.000    0.000    0.000 _weakrefset.py:79(add)
        1    0.000    0.000    0.000    0.000 codecs.py:77(__new__)
        1    0.027    0.027   24.864   24.864 setup.py:4(<module>)
        1    0.015    0.015    0.016    0.016 threading.py:1(<module>)
        2    0.000    0.000    0.000    0.000 threading.py:173(Condition)
        1    0.000    0.000    0.000    0.000 threading.py:176(_Condition)
        2    0.000    0.000    0.000    0.000 threading.py:178(__init__)
        1    0.000    0.000    0.000    0.000 threading.py:218(_is_owned)
        1    0.000    0.000    0.000    0.000 threading.py:285(notify)
        1    0.000    0.000    0.000    0.000 threading.py:303(notify_all)
        1    0.000    0.000    0.000    0.000 threading.py:312(_Semaphore)
        1    0.000    0.000    0.000    0.000 threading.py:370(_BoundedSemaphore)
        1    0.000    0.000    0.000    0.000 threading.py:382(Event)
        1    0.000    0.000    0.000    0.000 threading.py:385(_Event)
        1    0.000    0.000    0.000    0.000 threading.py:389(__init__)
        1    0.000    0.000    0.000    0.000 threading.py:403(set)
        1    0.000    0.000    0.000    0.000 threading.py:439(Barrier)
        1    0.000    0.000    0.000    0.000 threading.py:44(_Verbose)
        4    0.000    0.000    0.000    0.000 threading.py:46(__init__)
        1    0.000    0.000    0.000    0.000 threading.py:51(_note)
        1    0.000    0.000    0.000    0.000 threading.py:595(BrokenBarrierError)
        1    0.000    0.000    0.000    0.000 threading.py:615(Thread)
        1    0.000    0.000    0.000    0.000 threading.py:627(__init__)
        1    0.000    0.000    0.000    0.000 threading.py:719(_set_ident)
        1    0.000    0.000    0.000    0.000 threading.py:923(_Timer)
        1    0.000    0.000    0.000    0.000 threading.py:952(_MainThread)
        1    0.000    0.000    0.000    0.000 threading.py:954(__init__)
        1    0.000    0.000    0.000    0.000 threading.py:96(_RLock)
        1    0.000    0.000    0.000    0.000 threading.py:961(_set_daemon)
        1    0.000    0.000    0.000    0.000 threading.py:992(_DummyThread)
        1    0.000    0.000    0.000    0.000 utf_32_be.py:13(IncrementalEncoder)
        1    0.000    0.000    0.000    0.000 utf_32_be.py:17(IncrementalDecoder)
        1    0.000    0.000    0.000    0.000 utf_32_be.py:20(StreamWriter)
        1    0.000    0.000    0.000    0.000 utf_32_be.py:23(StreamReader)
        1    0.000    0.000    0.000    0.000 utf_32_be.py:28(getregentry)
        1    0.000    0.000    0.000    0.000 utf_32_be.py:3(<module>)
       20    0.002    0.000    0.002    0.000 {built-in method __build_class__}
        1    0.015    0.015    0.015    0.015 {built-in method __import__}
        1    0.000    0.000    0.000    0.000 {built-in method __new__ of type object at 0x78ce60}
        3    0.000    0.000    0.000    0.000 {built-in method allocate_lock}
        1    0.000    0.000   24.864   24.864 {built-in method exec}
        1    0.000    0.000    0.000    0.000 {built-in method get_ident}
       15    0.000    0.000    0.000    0.000 {built-in method isinstance}
        1    0.000    0.000    0.000    0.000 {built-in method len}
        1    0.008    0.008    0.008    0.008 {built-in method load_from_file}
      706    0.138    0.000    0.138    0.000 {built-in method print}
        2    0.000    0.000    0.000    0.000 {method 'acquire' of '_thread.lock' objects}
        1    0.000    0.000    0.000    0.000 {method 'add' of 'set' objects}
     2071    0.001    0.000    0.001    0.000 {method 'append' of 'list' objects}
      706    0.001    0.000    0.001    0.000 {method 'as_milliseconds' of 'sfml.Time' objects}
      706    0.012    0.000    0.012    0.000 {method 'clear' of 'sfml.RenderTarget' objects}
        1    0.090    0.090    0.090    0.090 {method 'close' of 'sfml.RenderWindow' objects}
        1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}
      706   23.442    0.033   23.442    0.033 {method 'display' of 'sfml.RenderWindow' objects}
   499142    0.423    0.000    0.423    0.000 {method 'draw' of 'sfml.RenderTarget' objects}
        3    0.000    0.000    0.000    0.000 {method 'get' of 'dict' objects}
        9    0.000    0.000    0.000    0.000 {method 'isalnum' of 'str' objects}
      706    0.000    0.000    0.000    0.000 {method 'iter_events' of 'sfml.RenderWindow' objects}
        1    0.000    0.000    0.000    0.000 {method 'join' of 'str' objects}
        1    0.000    0.000    0.000    0.000 {method 'release' of '_thread.lock' objects}
        1    0.000    0.000    0.000    0.000 {method 'replace' of 'str' objects}
      706    0.000    0.000    0.000    0.000 {method 'restart' of 'sfml.Clock' objects}
        2    0.000    0.000    0.000    0.000 {method 'setter' of 'property' objects}

Brefs je ne pense pas que cela vient directement de mon algorithme (je peux me tromper ;) ).

édit : c'est corrigé/ Le problème venait de la variable drawable présent dans la méthode Window.show qui ne se réinitialisait pas correctement, donc cela signifiait plus de draw et donc un display de plus en plus long au cours du temps.
« Modifié: Avril 06, 2012, 10:24:12 pm par gaulois94 »

 

anything