dvips -o and other makefile consmetics
[PyX/mjg.git] / test / profile_path.py
blobeb1dd0ce11b2ed3de5d58f53b61fa4d7bf7f98de
1 #!/usr/bin/env python
2 import sys
3 sys.path[:0] = [".."]
5 import pyx
6 from pyx import *
7 from pyx.path import *
9 import profile
10 import pstats
12 def testspeed():
13 "coordinates as strings"
15 c=canvas.canvas()
16 p=path(moveto(0,0))
18 for i in xrange(1000):
19 p.append(lineto("%d pt" % i, "%d pt" % i))
21 c.stroke(p)
22 c.writetofile("testspeed")
24 def testspeed2():
25 "coordinates in user units"
27 c=canvas.canvas()
28 p=path(moveto(0,0))
30 for i in xrange(1000):
31 p.append(lineto(i,i))
33 c.stroke(p)
34 c.writetofile("testspeed")
36 def testspeed3():
37 "coordinates in pts (internal routines)"
39 c=canvas.canvas()
40 p=path(pyx.path._moveto(0,0))
42 for i in xrange(1000):
43 p.append(pyx.path._lineto(i, i))
45 c.stroke(p)
46 c.writetofile("testspeed")
48 def testspeedintersect():
49 p=path(moveto(10,10), curveto(12,16,14,15,12,19))
50 bp=normpath(p)
52 for x in xrange(1,100):
53 q=path(moveto(x/5.0,10), curveto(12,16,14,22,11,16))
54 bq=normpath(q)
55 isect = bp.intersect(bq, epsilon=1e-3)
57 profile.run('testspeed()', 'test.prof')
58 pstats.Stats("test.prof").sort_stats('time').print_stats(10)
60 profile.run('testspeed2()', 'test.prof')
61 pstats.Stats("test.prof").sort_stats('time').print_stats(10)
63 profile.run('testspeed3()', 'test.prof')
64 pstats.Stats("test.prof").sort_stats('time').print_stats(10)
66 profile.run('testspeedintersect()', 'test.prof')
67 pstats.Stats("test.prof").sort_stats('time').print_stats(10)