-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_expect.py
40 lines (29 loc) · 1.71 KB
/
generate_expect.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
import numpy as np
import time
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Generate Expect Numpy Array')
parser.add_argument('-s', '--sample', help='sample file name', action='store', type=str, required=True)
parser.add_argument('-e', '--expect', help='expect file name', action='store', type=str, required=True)
parser.add_argument('-l', '--log' , help='log file name' , action='store', type=str, default="")
args = parser.parse_args()
print ("generate_expect: sample_file : {0}".format(args.sample))
print ("generate_expect: expect_file : {0}".format(args.expect))
sample = np.load(args.sample)
print ("generate_expect: size : {0}".format(sample.size))
start_time = time.time()
expect = np.argsort(sample).astype(np.uint32)
elapsed_time = time.time() - start_time
np.save(args.expect, expect)
average_time = round(elapsed_time*1000.0,3)
throughput = round(((sample.size/elapsed_time)/(1000*1000)),3)
print ("generate_expect: average_time : {0:>8.3f} # [msec]" .format(average_time))
print ("generate_expect: throughput : {0:>8.3f} # [mwords/sec]".format(throughput ))
if args.log != '':
with open(args.log, mode='a') as f:
print ("-", file=f)
print (" sample_file : {0}".format(args.sample), file=f)
print (" expect_file : {0}".format(args.expect), file=f)
print (" size : {0}".format(sample.size), file=f)
print (" average_time : {0:>8.3f} # [msec]" .format(average_time), file=f)
print (" throughput : {0:>8.3f} # [mwords/sec]".format(throughput ), file=f)