Add dashboard template
[scripts.git] / elastic / generate-config.py
1 #!/usr/bin/env python3
2
3 import json
4 import pystache
5
6 #print(pystache.render('Hi {{person}}!', {'person': 'Mom'}))
7
8 tests_json = '{ "tests":[\
9     {"name": "test_encrypt_raw_10M"},\
10     {"name": "test_encrypt_raw_100k"},\
11     {"name": "test_encrypt_raw_10k"},\
12     {"name": "test_decrypt_raw_100k"},\
13     {"name": "test_decrypt_raw_10M"},\
14     {"name": "test_decrypt_raw_10k"},\
15     {"name": "test_decrypt_raw_1M"},\
16     {"name": "test_decrypt_raw_500k"},\
17     {"name": "test_encrypt_raw_1M"},\
18     {"name": "test_encrypt_raw_500k"},\
19     {"name": "test_initialization"},\
20     {"name": "test_async_create_1000_10k"},\
21     {"name": "test_async_create_100_100k"},\
22     {"name": "test_create_1000_10k"},\
23     {"name": "test_create_100_100k"},\
24     {"name": "test_create_20_500k"},\
25     {"name": "test_decrypt_doc_100k"},\
26     {"name": "test_decrypt_doc_10M"},\
27     {"name": "test_decrypt_doc_10k"},\
28     {"name": "test_decrypt_doc_1M"}\
29     ]}'
30
31 tests = json.loads(tests_json)
32
33
34 # Generate visualizations
35 def generate_visualizations():
36     dir = './visualization/'
37     template = open(dir + 'template.mustache', 'r').read()
38
39     # test_names = tests.
40     for test in tests['tests']:
41         test_name = test['name']
42         out_file = dir + test_name + '.json'
43         print('Generating ' + out_file)
44         context = {
45            'title': test_name,
46            'query': "commit_info.project:soledad AND commit_info.branch='master' AND machine_info.host='weasel' AND name='" + test_name + "'"
47         }
48
49         rendered = pystache.render(template, context)
50
51         out = open(out_file, 'w')
52         out.write(rendered)
53         out.flush()
54
55 # Generate Dashboard
56 def generate_dashboards():
57     dir = './dashboard/'
58     template = open(dir + 'template.mustache', 'r').read()
59     out_file = dir + 'soledad-benchmarks.json'
60     print('Generating ' + out_file)
61
62     rendered = pystache.render(template, tests)
63     #print(rendered)
64
65     out = open(out_file, 'w')
66     out.write(rendered)
67     out.flush()
68
69
70 # Main
71
72 generate_dashboards()
73 generate_visualizations()