scale_load.py 2.36 KB
Newer Older
Antoine Kaufmann's avatar
Antoine Kaufmann committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Copyright 2021 Max Planck Institute for Software Systems, and
# National University of Singapore
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Jonas Kaufmann's avatar
Jonas Kaufmann committed
23
24
import json
import math
Hejing Li's avatar
Hejing Li committed
25
import os
Jonas Kaufmann's avatar
Jonas Kaufmann committed
26
import sys
Hejing Li's avatar
Hejing Li committed
27

28
num_runs = 3
Hejing Li's avatar
Hejing Li committed
29
if len(sys.argv) != 2:
Hejing Li's avatar
Hejing Li committed
30
    print('Usage: python3 ScaleLoad.py OUTDIR')
Hejing Li's avatar
Hejing Li committed
31
32
33
    sys.exit(1)

basedir = sys.argv[1] + '/'
34

35
# FIXME: dropped 120 because it looks off
Hejing Li's avatar
Hejing Li committed
36
types_of_bw = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]
Hejing Li's avatar
Hejing Li committed
37
38

for bw in types_of_bw:
39
40
41
42
    total_time = 0
    avg_time = 0
    std = 0
    all_time = []
Jonas Kaufmann's avatar
Jonas Kaufmann committed
43
    for i in range(1, num_runs + 1):
Jonas Kaufmann's avatar
Jonas Kaufmann committed
44
        log_path = f'{basedir}gt-ib-sw-Load-{bw}m-{i}.json'
45

Jonas Kaufmann's avatar
Jonas Kaufmann committed
46
47
48
49
50
51
52
53
54
55
        diff_time = ''
        if os.path.exists(log_path):
            with open(log_path, 'r', encoding='utf-8') as log:
                exp_log = json.load(log)
                start_time = exp_log['start_time']
                end_time = exp_log['end_time']
                diff_time = (end_time - start_time) / 60  #min
                total_time += diff_time
                all_time.append(diff_time)
                diff_time = str(diff_time)
56
57
58

        #print('%d\t%s' % (bw, diff_time))

Jonas Kaufmann's avatar
Jonas Kaufmann committed
59
    avg_time = total_time / num_runs
60
61
62
63
    #print('avg_time: ' + str(avg_time))

    for i in range(0, num_runs):
        std += (all_time[i] - avg_time) * (all_time[i] - avg_time)
Jonas Kaufmann's avatar
Jonas Kaufmann committed
64
65

    std = std / num_runs
66
67
    std = math.sqrt(std)
    #print(str(std))
Jonas Kaufmann's avatar
Jonas Kaufmann committed
68
    print(f'{bw} {avg_time} {std}')