예제 #1
0
 def tfunc(ts, fn, fontSize, enc):
     w1 = stringWidthU(ts, fn, fontSize, enc)
     w2 = _py_stringWidth(ts, fn, fontSize, enc)
     assert abs(
         w1 - w2
     ) < 1e-10, "stringWidthU(%r,%r,%s,%r)-->%r != _py_stringWidth(...)-->%r" % (
         ts, fn, fontSize, enc, w1, w2)
예제 #2
0
 def tfunc(ts,fn,fontSize,enc):
     w1 = stringWidthU(ts,fn,fontSize,enc)
     w2 = _py_stringWidth(ts,fn,fontSize,enc)
     assert abs(w1-w2)<1e-10,"stringWidthU(%r,%r,%s,%r)-->%r != _py_stringWidth(...)-->%r" % (ts,fn,fontSize,enc,w1,w2)
예제 #3
0
파일: t2.py 프로젝트: Distrotech/reportlab
from reportlab.pdfbase.pdfmetrics import _py_stringWidth
from _rl_accel import stringWidthU
import time
testCp1252 = 'copyright %s trademark %s registered %s ReportLab! Ol%s!' % (chr(169), chr(153),chr(174), chr(0xe9))
enc='cp1252'
assert stringWidthU('ABCDEF','Times-Roman',12)==_py_stringWidth('ABCDEF','Times-Roman',12)
assert stringWidthU(testCp1252,'Times-Roman',12,enc)==_py_stringWidth(testCp1252,'Times-Roman',12,enc)
def tim(N,msg,func,*args):
    t0 = time.time()
    for i in range(N):
        x = func(*args)
    t1 = time.time()
    return "%s N=%d t=%.3f\n%r" % (msg,N,t1-t0,x)

print(tim(1000000,'_py_stringWidth',_py_stringWidth,'ABCDEF','Times-Roman',12))
print(tim(1000000,'stringWidthU',stringWidthU,'ABCDEF','Times-Roman',12))
예제 #4
0
from reportlab.pdfbase.pdfmetrics import _py_stringWidth
from _rl_accel import stringWidthU
import time
testCp1252 = 'copyright %s trademark %s registered %s ReportLab! Ol%s!' % (
    chr(169), chr(153), chr(174), chr(0xe9))
enc = 'cp1252'
assert stringWidthU('ABCDEF', 'Times-Roman',
                    12) == _py_stringWidth('ABCDEF', 'Times-Roman', 12)
assert stringWidthU(testCp1252, 'Times-Roman', 12,
                    enc) == _py_stringWidth(testCp1252, 'Times-Roman', 12, enc)


def tim(N, msg, func, *args):
    t0 = time.time()
    for i in range(N):
        x = func(*args)
    t1 = time.time()
    return "%s N=%d t=%.3f\n%r" % (msg, N, t1 - t0, x)


print(
    tim(1000000, '_py_stringWidth', _py_stringWidth, 'ABCDEF', 'Times-Roman',
        12))
print(tim(1000000, 'stringWidthU', stringWidthU, 'ABCDEF', 'Times-Roman', 12))
예제 #5
0
파일: t2.py 프로젝트: nakagami/reportlab
from reportlab.pdfbase.pdfmetrics import _py_stringWidth
from _rl_accel import stringWidthU
import time

testCp1252 = "copyright %s trademark %s registered %s ReportLab! Ol%s!" % (chr(169), chr(153), chr(174), chr(0xE9))
enc = "cp1252"
assert stringWidthU("ABCDEF", "Times-Roman", 12) == _py_stringWidth("ABCDEF", "Times-Roman", 12)
assert stringWidthU(testCp1252, "Times-Roman", 12, enc) == _py_stringWidth(testCp1252, "Times-Roman", 12, enc)


def tim(N, msg, func, *args):
    t0 = time.time()
    for i in range(N):
        x = func(*args)
    t1 = time.time()
    return "%s N=%d t=%.3f\n%r" % (msg, N, t1 - t0, x)


print tim(1000000, "_py_stringWidth", _py_stringWidth, "ABCDEF", "Times-Roman", 12)
print tim(1000000, "stringWidthU", stringWidthU, "ABCDEF", "Times-Roman", 12)