~ubuntu-branches/ubuntu/trusty/python-enable/trusty

« back to all changes in this revision

Viewing changes to examples/kiva/agg/examples/benchmark.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2010-10-17 23:10:41 UTC
  • mto: (1.2.1 upstream) (8.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20101017231041-rziowhgl7zhxra2i
Tags: upstream-3.3.2
ImportĀ upstreamĀ versionĀ 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
"""
2
2
Benchmarks Agg rendering times.
3
3
"""
 
4
from __future__ import with_statement
4
5
 
5
6
import time
6
7
 
135
136
    gc.set_stroke_color((0.0,1.0,0.0,0.6))
136
137
    t1 = time.clock()
137
138
    for x,y in pts:
138
 
        gc.save_state()
139
 
        gc.translate_ctm(x,y)
140
 
        gc.add_path(star_path)
141
 
        gc.draw_path()
142
 
        gc.restore_state()
 
139
        with gc:
 
140
            gc.translate_ctm(x,y)
 
141
            gc.add_path(star_path)
 
142
            gc.draw_path()
143
143
    t2 = time.clock()
144
144
    gc.save("benchmark_symbols1.bmp")
145
145
    tot_time = t2 - t1
159
159
    gc.set_stroke_color((0.0,1.0,0.0,0.6))
160
160
    t1 = time.clock()
161
161
    for x,y in pts:
162
 
        gc.save_state()
163
 
        gc.translate_ctm(x,y)
164
 
        gc.rect(-2.5,-2.5,5,5)
165
 
        gc.draw_path()
166
 
        gc.restore_state()
 
162
        with gc:
 
163
            gc.translate_ctm(x,y)
 
164
            gc.rect(-2.5,-2.5,5,5)
 
165
            gc.draw_path()
167
166
    t2 = time.clock()
168
167
    gc.save("benchmark_rect.bmp")
169
168
    tot_time = t2 - t1