-
-
Save immerrr/a1419c4175d9c59d1cb6 to your computer and use it in GitHub Desktop.
splash multi-page benchmark script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import argparse | |
""" | |
Benchmark script. | |
""" | |
from splash.tests.stress import benchmark_png | |
import pandas as pd | |
from base64 import standard_b64decode | |
from PIL import Image | |
from cStringIO import StringIO | |
parser = argparse.ArgumentParser(description=__doc__) | |
parser.add_argument('out_file', nargs='?', default='bench.pkl') | |
def main(): | |
args = parser.parse_args() | |
out_file = args.out_file | |
if not out_file.endswith('.pkl'): | |
out_file += '.pkl' | |
results = [] | |
for url in [ | |
"http://wikipedia.org", | |
"http://google.com", | |
"http://w3.org", | |
"http://w3.org/TR/2010/REC-xhtml-basic-20101123/", | |
"http://blog.pinterest.com", | |
"http://imgur.com", | |
]: | |
for (width, height) in [ | |
(None, None), (None, 500), (500, None), (500, 500), | |
(2000, None), (2000, 2000), (2100, None)]: | |
result = {'url': url, 'width': width, 'height': height} | |
# if result != {'url': "http://w3.org/TR/2010/REC-xhtml-basic-20101123/", | |
# 'width': None, 'height': None}: continue | |
try: | |
result.update(benchmark_png(url=url, width=width, | |
height=height, timeout=180.)) | |
img = Image.open(StringIO(standard_b64decode(result['png']))) | |
del result['png'] | |
result['imgsize'] = "%dx%d" % img.size | |
except Exception: | |
import traceback | |
print traceback.format_exc() | |
finally: | |
results.append(result) | |
df = pd.DataFrame(results).set_index(['url', 'width', 'height']) | |
print df | |
df.to_pickle(args.out_file) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment