File size: 1,711 Bytes
151b875
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import argparse
import pickle
import matplotlib.pyplot as plt

def main(stats_file):
    with open(stats_file, 'rb') as file:
        stats = pickle.load(file)

    # The imported stats is a list of dicts. Each dict corresponds to a generated sequence.
    # The keys of a dict are (num_instr, interval) tuples. The values of the dict
    # are lists of times taken to generate each interval. 

    times_by_num_instr = {}
    interval = None
    for sample in stats:
        for key, value in sample.items():
            num_instr, interval = key
            if not interval:
                interval = interval
            else:
                assert interval == interval

            if num_instr in times_by_num_instr:
                times_by_num_instr[num_instr].extend(value)
            else:
                times_by_num_instr[num_instr] = value 

    means = []
    stds = []
    for key, value in times_by_num_instr.items():
        mean = sum(value) / len(value)
        std = (sum([(x - mean)**2 for x in value]) / len(value))**.5
        means.append(mean)
        stds.append(std)

    plt.axhline(y=interval, linestyle='--', color='red', label='Real-time')
    plt.errorbar(times_by_num_instr.keys(), means, yerr=stds, fmt='o')
    plt.xlabel('Number of Instruments')
    plt.ylabel('Time (s)')
    plt.title(f'Generation Time of {interval}s Intervals by Number of Instruments')
    plt.legend() 
    plt.show()

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Plot benchmark data')
    parser.add_argument('stats_file', type=str, help='Path to the stats file')
    args = parser.parse_args()
    main(args.stats_file)