summaryrefslogtreecommitdiff
path: root/elastic/generate-config.py
blob: 31c8e3a93aa6d0b8c143b092845b99863a1e4eeb (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python3

import json
import pystache

#print(pystache.render('Hi {{person}}!', {'person': 'Mom'}))

tests_json = '{ "tests":[\
    {"name": "test_encrypt_raw_10M"},\
    {"name": "test_encrypt_raw_100k"},\
    {"name": "test_encrypt_raw_10k"},\
    {"name": "test_decrypt_raw_100k"},\
    {"name": "test_decrypt_raw_10M"},\
    {"name": "test_decrypt_raw_10k"},\
    {"name": "test_decrypt_raw_1M"},\
    {"name": "test_decrypt_raw_500k"},\
    {"name": "test_encrypt_raw_1M"},\
    {"name": "test_encrypt_raw_500k"},\
    {"name": "test_initialization"},\
    {"name": "test_async_create_1000_10k"},\
    {"name": "test_async_create_100_100k"},\
    {"name": "test_create_1000_10k"},\
    {"name": "test_create_100_100k"},\
    {"name": "test_create_20_500k"},\
    {"name": "test_decrypt_doc_100k"},\
    {"name": "test_decrypt_doc_10M"},\
    {"name": "test_decrypt_doc_10k"},\
    {"name": "test_decrypt_doc_1M"}\
    ]}'

tests = json.loads(tests_json)


# Generate visualizations
def generate_visualizations():
    dir = './visualization/'
    template = open(dir + 'template.mustache', 'r').read()

    # test_names = tests.
    for test in tests['tests']:
        test_name = test['name']
        out_file = dir + test_name + '.json'
        print('Generating ' + out_file)
        context = {
           'title': test_name,
           'query': "commit_info.project:soledad AND commit_info.branch='master' AND machine_info.host='weasel' AND name='" + test_name + "'"
        }

        rendered = pystache.render(template, context)

        out = open(out_file, 'w')
        out.write(rendered)
        out.flush()

# Generate Dashboard
def generate_dashboards():
    dir = './dashboard/'
    template = open(dir + 'template.mustache', 'r').read()
    out_file = dir + 'soledad-benchmarks.json'
    print('Generating ' + out_file)

    panels = '['
    count = 0
    for test in tests['tests']:
        test_name = test['name']
        count += 1
        panels += '{\\"id\\":\\"' + test_name + '\\",\\"panelIndex\\":' + str(count) + ',\\"col\\":1,\\"row\\":' + str(count) + ',\\"size_x\\":6,\\"size_y\\":3,\\"type\\":\\"visualization\\"}, '
    panels = panels[:-2]
    panels += ']'

    print(panels)
    panels_json = { 'panels_json': panels }
    rendered = pystache.render(template, panels_json)
    #print(rendered)

    out = open(out_file, 'w')
    out.write(rendered)
    out.flush()


# Main

generate_dashboards()
generate_visualizations()