# calculates throughput in gib/s from the meassured # transfer duration (in nanoseconds) for a given element # with the size of this given in bytes def calc_throughput(size_bytes,time_ns): time_seconds = time_ns * 1e-9 size_gib = size_bytes / (1024 ** 3) throughput_gibs = size_gib / time_seconds return throughput_gibs # reverse array search: return index of value in array def index_from_element(value,array): for (idx,val) in enumerate(array): if val == value: return idx return 0