#!/usr/bin/python import os tex_template = """ \\begin{{figure}}[!htb] \\centering \\includegraphics[width=.75\\linewidth]{{./results-benchmark/{filename}}} \\caption{{{caption}}} \\label{{fig:{label}}} \\end{{figure}} """ caption_template = '{chart} benchmark result of {device} device with {browser} browser on dataset "{data}" {highQual}.' devices = { 'win': 'Windows', 'mac': 'MacBook Pro', 'ubu': 'Ubuntu', 'iph': 'iPhone' } browsers = { 'ffox': 'Firefox', 'chro': 'Chrome', 'edge': 'Edge', 'safa': 'Safari' } data = { 'simplify': 'Simplify.js example', 'bavaria': 'Bavaria outline' } chart = { 'vs': 'Simplify.wasm vs. Simplify.js', 'stack': 'Simplify.wasm runtime analysis', 'jsstack': 'Turf.js simplify' } highQual = { 'true': 'with high quality mode', 'false': 'without high quality mode' } for filename in os.listdir(os.path.dirname(os.path.realpath(__file__))): if not filename.endswith('.png'): continue label = filename.split('.')[0] parts = label.split('_') caption = caption_template.format( device=devices[parts[0]], browser=browsers[parts[1]], data=data[parts[2]], chart=chart[parts[3]], highQual=highQual[parts[4]] ) content = tex_template.format( filename=filename, caption=caption, label=label) with open(label + '.tex', 'w') as file: file.write(content)