forked from esloho/Qrangen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmark_app.py
58 lines (45 loc) · 1.56 KB
/
benchmark_app.py
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
import argparse
from src.benchmark import Benchmark
def main(args):
mode = args.mode
iterations = args.number_amount
bits = args.bits
if mode not in range(3):
raise Exception('Mode ' + str(mode) + ' not allowed.')
if iterations < 0:
raise Exception('Amount ' + str(iterations) + ' not allowed.')
if bits < 0:
raise Exception('Number of bits ' + str(bits) + ' not allowed.')
benchmark = Benchmark(mode, iterations, bits)
results = (benchmark.execute())
print(results)
def print_help():
print("""-m --mode : Simulation mode: 0 for local | 1 for IBM server
simulation | 2 for IBM server REAL experiment\n\n"""
+ """-n --number_amount : Amount of numbers to generate.
Must be greater than 0\n\n"""
+ """"-b --bits : Generates a random number between 0 and 2**b-1,
i.e., a number with b binary bits""")
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(
'-m',
'--mode',
help="""Simulation mode: 0 for local | 1 for IBM server
simulation | 2 for IBM server REAL experiment""",
default=0,
type=int)
parser.add_argument(
'-n',
'--number_amount',
help="Amount of numbers to generate. Needs to be greater than 0",
default=1,
type=int)
parser.add_argument(
'-b',
'--bits',
help="""Generates numbers of b bits""",
default=1,
type=int)
parsed_args = parser.parse_args()
main(parsed_args)