t0.py :  » PDF » ReportLab » ReportLab_2_4 » src » rl_addons » rl_accel » tests » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » PDF » ReportLab 
ReportLab » ReportLab_2_4 » src » rl_addons » rl_accel » tests » t0.py
import os, time, sys
from reportlab.pdfbase.pdfmetrics import _py_getFont,_py_unicode2T1
from _rl_accel import unicode2T1
from getrc import getrc,checkrc
utext = 'ABCDEF \xce\x91BCDEF\xce\x91'.decode('utf8')
utext = 'This is the end of the \xce\x91\xce\xb2 world. This is the end of the \xce\x91\xce\xb2 world jap=\xe3\x83\x9b\xe3\x83\x86. This is the end of the \xce\x91\xce\xb2 world. This is the end of the \xce\x91\xce\xb2 world jap=\xe3\x83\x9b\xe3\x83\x86'.decode('utf8')
fontName = 'Times-Roman'
fontSize=12
N = 30000
def tim(msg,func,*args):
    t0 = time.time()
    for i in xrange(N):
        x = func(*args)
    t1 = time.time()
    return "%s N=%d t=%.3f\n%r" % (msg,N,t1-t0,x)

#print tim('_py_stringWidth', _py_stringWidth, utext, fontName, fontSize)
#print tim('stringWidth2', stringWidth2, utext, fontName, fontSize)

font = _py_getFont(fontName)
assert unicode2T1(utext,[font]+font.substitutionFonts)==_py_unicode2T1(utext,[font]+font.substitutionFonts)
#print unicode2T1(u'ABCDEF',[font]+font.substitutionFonts)
#print _py_unicode2T1(u'ABCDEF',[font]+font.substitutionFonts)
defns = "font font.widths font.substitutionFonts font.encName fontName utext"
rcv = getrc(defns)
print tim('unicode2T1',unicode2T1,utext,[font]+font.substitutionFonts)
print tim('_py_unicode2T1',_py_unicode2T1,utext,[font]+font.substitutionFonts)
print "rc diffs=(%s)" % checkrc(defns,rcv)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.