~bennabiy/+junk/python-xlib

« back to all changes in this revision

Viewing changes to .pc/python3.patch/examples/profilex.py

  • Committer: Package Import Robot
  • Author(s): Andrew Shadura, Ramkumar Ramachandra, Andrew Shadura
  • Date: 2015-08-13 08:14:19 UTC
  • mfrom: (6.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20150813081419-hdefinnghp2iydkx
Tags: 0.14+20091101-3
[ Ramkumar Ramachandra ]
* Remove useless debugging output (Closes: #565996)

[ Andrew Shadura ]
* Switch to 3.0 (quilt) format.
* Rename patches.
* Use debhelper 9 in its short form.
* Use pybuild.
* Bump Standards-Version.
* Don't build or install PostScript documentation and info files.
* Use system-provided texi2html instead of a shipped version
  (Closes: #795057).
* Update debian/copyright (Closes: #795057).
* Don't install Makefile or texi2html with the documentation.
* Set executable bit for examples.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
#
 
3
# Program to generate profiling data.  Run with one argument,
 
4
# the profile stats file to generate.
 
5
 
 
6
import sys
 
7
import os
 
8
 
 
9
# Change path so we find Xlib
 
10
sys.path.insert(1, os.path.join(sys.path[0], '..'))
 
11
 
 
12
from Xlib import X, display, Xatom
 
13
 
 
14
import profile
 
15
 
 
16
def dostuff():
 
17
    d = display.Display()
 
18
    r = d.screen().root
 
19
    cm = d.screen().default_colormap
 
20
 
 
21
    for i in xrange(0, 1000):
 
22
        if i % 50 == 0:
 
23
            print 'Iteration', i
 
24
 
 
25
        r.delete_property(Xatom.WM_NORMAL_HINTS)
 
26
        r.delete_property(Xatom.WM_NORMAL_HINTS)
 
27
        r.get_geometry()
 
28
        r.get_geometry()
 
29
        r.delete_property(Xatom.WM_NORMAL_HINTS)
 
30
        r.delete_property(Xatom.WM_NORMAL_HINTS)
 
31
        r.change_property(Xatom.WM_NORMAL_HINTS, Xatom.STRING, 32, [1, 2, 3, 4])
 
32
        r.query_tree()
 
33
        cm.query_colors([0, 1, 2, 3, 4, 5, 6, 7])
 
34
 
 
35
def main(filename):
 
36
    profile.run('dostuff()', filename)
 
37
 
 
38
if __name__ == '__main__':
 
39
    if len(sys.argv) == 2:
 
40
        main(sys.argv[1])
 
41
    else:
 
42
        print sys.argv[0], "<filename to write profile output to>"