"Fossies" - the Fresh Open Source Software Archive

Member "reportlab-3.5.32/src/rl_addons/rl_accel/tests/t2.py" (1 Oct 2019, 747 Bytes) of package /linux/privat/reportlab-3.5.32.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 from reportlab.pdfbase.pdfmetrics import _py_stringWidth
    2 from _rl_accel import stringWidthU
    3 import time
    4 testCp1252 = 'copyright %s trademark %s registered %s ReportLab! Ol%s!' % (chr(169), chr(153),chr(174), chr(0xe9))
    5 enc='cp1252'
    6 assert stringWidthU('ABCDEF','Times-Roman',12)==_py_stringWidth('ABCDEF','Times-Roman',12)
    7 assert stringWidthU(testCp1252,'Times-Roman',12,enc)==_py_stringWidth(testCp1252,'Times-Roman',12,enc)
    8 def tim(N,msg,func,*args):
    9     t0 = time.time()
   10     for i in range(N):
   11         x = func(*args)
   12     t1 = time.time()
   13     return "%s N=%d t=%.3f\n%r" % (msg,N,t1-t0,x)
   14 
   15 print(tim(1000000,'_py_stringWidth',_py_stringWidth,'ABCDEF','Times-Roman',12))
   16 print(tim(1000000,'stringWidthU',stringWidthU,'ABCDEF','Times-Roman',12))