1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
from string import lowercase, uppercase
import os
import time
from kiva.image import font_metrics_provider as FMP
from kiva.fonttools import Font
counts = (500,)
strings = ("hello", ) # lowercase + uppercase)
fonts = ( ("arial", 12), ) # ("times", 16), ("courier", 10) )
def test():
allmetrics = []
for count in counts:
start = time.time()
for i in range(count):
metrics = FMP()
for face, size in fonts:
metrics.set_font(Font(face, size))
for s in strings:
dims = metrics.get_text_extent(s)
allmetrics.append(metrics)
end = time.time()
print "finished count=%d" % count
print " total time:", end - start
print " time/set_font:", (end-start) / float(count * len(fonts))
if __name__ == "__main__":
test()
|