Results 1 to 10 of 10

Thread: [PyQt4] QTreeView performance issue

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: [PyQt4] QTreeView performance issue

    Are you running cProfile from the command line? i.e. python -m cProfile "scriptname"
    I get similar results that way.

    Try running it from your script:
    Qt Code:
    1. from PyQt4.QtCore import *
    2. from PyQt4.QtGui import *
    3. from random import shuffle
    4. from time import clock
    5. import cProfile
    6. import pstats
    7.  
    8. class TreeItem(object) :
    9. . . .
    10. . . .
    11. if __name__ == "__main__" :
    12. import sys
    13. a = QApplication(sys.argv)
    14. dia = Frame(None)
    15. dia.resize(400, 600)
    16. dia.show()
    17. cProfile.run('a.exec_()', 'profdata')
    18. p = pstats.Stats('profdata')
    19. p.sort_stats('calls').print_stats()
    20. # a.exec_()
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Nov 2012
    Posts
    14
    Qt products
    Platforms
    Windows

    Default Re: [PyQt4] QTreeView performance issue

    Yes, I was running cProfile from command line; I executed the profiling as you suggested and I got values more similar to yours:

    Qt Code:
    1. 1070281 function calls in 11.630 seconds
    2.  
    3. Ordered by: call count
    4.  
    5. ncalls tottime percall cumtime percall filename:lineno(function)
    6. 999999 0.102 0.000 0.102 0.000 {method 'random' of '_random.Random' objects}
    7. 12766 0.003 0.000 0.003 0.000 {built-in method internalPointer}
    8. 10632 0.005 0.000 0.005 0.000 {built-in method isValid}
    9. 6793 0.019 0.000 0.019 0.000 {built-in method createIndex}
    10. 3388 0.001 0.000 0.001 0.000 {len}
    11. 3375 0.002 0.000 0.003 0.000 C:\Users\massimiliano\Desktop\t.py:45(childCount)
    12. 3375 0.002 0.000 0.002 0.000 {built-in method column}
    13. 3321 0.009 0.000 0.015 0.000 C:\Users\massimiliano\Desktop\t.py:126(rowCount)
    14. 2961 0.001 0.000 0.001 0.000 C:\Users\massimiliano\Desktop\t.py:42(child)
    15. 2961 0.001 0.000 0.001 0.000 C:\Users\massimiliano\Desktop\t.py:89(columnCount)
    16. 2961 0.014 0.000 0.056 0.000 C:\Users\massimiliano\Desktop\t.py:106(index)
    17. 2961 0.017 0.000 0.031 0.000 {built-in method hasIndex}
    18. 2590 0.021 0.000 0.078 0.000 C:\Users\massimiliano\Desktop\t.py:80(_ItemFromIndex)
    19. 2590 0.008 0.000 0.086 0.000 C:\Users\massimiliano\Desktop\t.py:92(data)
    20. 2520 0.001 0.000 0.001 0.000 {built-in method row}
    21. 1706 0.001 0.000 0.001 0.000 C:\Users\massimiliano\Desktop\t.py:57(parent)
    22. 1706 0.009 0.000 0.019 0.000 C:\Users\massimiliano\Desktop\t.py:114(parent)
    23. 1312 0.002 0.000 0.003 0.000 C:\Users\massimiliano\Desktop\t.py:60(row)
    24. 1312 0.001 0.000 0.001 0.000 {method 'index' of 'list' objects}
    25. 370 0.000 0.000 0.000 0.000 C:\Users\massimiliano\Desktop\t.py:51(data)
    26. 370 0.002 0.000 0.002 0.000 C:\Users\massimiliano\Desktop\t.py:97(flags)
    27. 54 0.000 0.000 0.000 0.000 C:\Users\massimiliano\Desktop\t.py:100(hasChildren)
    28. 28 0.000 0.000 0.000 0.000 C:\Python27\lib\idlelib\rpc.py:149(debug)
    29. 20 0.000 0.000 0.000 0.000 {thread.get_ident}
    30. 20 0.000 0.000 0.000 0.000 C:\Python27\lib\threading.py:63(_note)
    31. 16 0.061 0.004 0.061 0.004 {method 'acquire' of 'thread.lock' objects}
    32. 8 0.000 0.000 0.000 0.000 {method 'release' of 'thread.lock' objects}
    33. 8 0.000 0.000 0.000 0.000 C:\Python27\lib\threading.py:58(__init__)
    34. 8 0.000 0.000 0.000 0.000 {thread.allocate_lock}
    35. 8 0.000 0.000 0.000 0.000 {isinstance}
    36. 8 0.000 0.000 0.000 0.000 C:\Python27\lib\threading.py:826(currentThread)
    37. 4 0.000 0.000 0.000 0.000 C:\Python27\lib\threading.py:141(release)
    38. 4 0.000 0.000 0.000 0.000 {getattr}
    39. 4 0.000 0.000 0.000 0.000 {method 'get' of 'dict' objects}
    40. 4 0.000 0.000 0.000 0.000 C:\Python27\lib\threading.py:186(__init__)
    41. 4 0.000 0.000 0.061 0.015 C:\Python27\lib\threading.py:235(wait)
    42. 4 0.000 0.000 0.000 0.000 C:\Python27\lib\threading.py:159(_acquire_restore)
    43. 4 0.000 0.000 0.000 0.000 C:\Python27\lib\threading.py:167(_release_save)
    44. 4 0.000 0.000 0.000 0.000 C:\Python27\lib\idlelib\rpc.py:317(newseq)
    45. 4 0.000 0.000 0.000 0.000 C:\Python27\lib\threading.py:177(_is_owned)
    46. 4 0.000 0.000 0.000 0.000 C:\Python27\lib\threading.py:101(RLock)
    47. 4 0.000 0.000 0.000 0.000 C:\Python27\lib\socket.py:223(meth)
    48. 4 0.000 0.000 0.062 0.015 C:\Python27\lib\idlelib\rpc.py:279(getresponse)
    49. 4 0.000 0.000 0.001 0.000 C:\Python27\lib\idlelib\rpc.py:218(asynccall)
    50. 4 0.000 0.000 0.062 0.015 C:\Python27\lib\idlelib\rpc.py:295(_getresponse)
    51. 4 0.000 0.000 0.000 0.000 C:\Python27\lib\threading.py:106(__init__)
    52. 4 0.000 0.000 0.000 0.000 C:\Python27\lib\idlelib\rpc.py:244(decoderesponse)
    53. 4 0.000 0.000 0.000 0.000 {select.select}
    54. 4 0.000 0.000 0.062 0.015 C:\Python27\lib\idlelib\rpc.py:238(asyncreturn)
    55. 4 0.000 0.000 0.000 0.000 {_struct.pack}
    56. 4 0.000 0.000 0.001 0.000 C:\Python27\lib\idlelib\rpc.py:321(putmessage)
    57. 4 0.000 0.000 0.063 0.016 C:\Python27\lib\idlelib\rpc.py:594(__call__)
    58. 4 0.000 0.000 0.063 0.016 C:\Python27\lib\idlelib\rpc.py:208(remotecall)
    59. 4 0.000 0.000 0.000 0.000 {cPickle.dumps}
    60. 4 0.000 0.000 0.000 0.000 {method 'fileno' of '_socket.socket' objects}
    61. 4 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects}
    62. 4 0.000 0.000 0.000 0.000 C:\Python27\lib\idlelib\rpc.py:546(__getattr__)
    63. 4 0.000 0.000 0.000 0.000 C:\Python27\lib\idlelib\rpc.py:589(__init__)
    64. 4 0.000 0.000 0.000 0.000 C:\Python27\lib\idlelib\rpc.py:287(_proxify)
    65. 4 0.000 0.000 0.000 0.000 C:\Python27\lib\threading.py:181(Condition)
    66. 4 0.001 0.000 0.001 0.000 {method 'send' of '_socket.socket' objects}
    67. 4 0.000 0.000 0.000 0.000 C:\Python27\lib\threading.py:121(acquire)
    68. 2 0.000 0.000 0.000 0.000 {time.clock}
    69. 2 0.000 0.000 0.000 0.000 {built-in method model}
    70. 1 0.003 0.003 0.003 0.003 {built-in method expand}
    71. 1 0.000 0.000 1.371 1.371 C:\Users\massimiliano\Desktop\t.py:142(Shuffle)
    72. 1 10.139 10.139 11.630 11.630 {built-in method exec_}
    73. 1 0.000 0.000 11.630 11.630 <string>:1(<module>)
    74. 1 1.203 1.203 1.305 1.305 C:\Python27\lib\random.py:276(shuffle)
    75. 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
    To copy to clipboard, switch view to plain text mode 

    To be honest, I really don't understand what's going on...

Similar Threads

  1. Replies: 2
    Last Post: 8th December 2010, 20:37
  2. [PyQt4] PyQt4 + gcin issue
    By fieliapm in forum Installation and Deployment
    Replies: 0
    Last Post: 28th September 2010, 08:04
  3. Performance issue
    By Skorpien126 in forum Qt Programming
    Replies: 4
    Last Post: 2nd July 2010, 16:02
  4. PyQt4 - QPlainTextEdit: performance when hidding blocks
    By josemaria.alkala in forum Newbie
    Replies: 6
    Last Post: 27th June 2010, 14:58
  5. Performance Issue
    By linuxdev in forum Qt Programming
    Replies: 1
    Last Post: 10th December 2008, 15:00

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.