Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def run_benchmarks(N, size):
timings = {}
nframes = compute_nframes(N, size);
actual_size = compute_actual_size(N, nframes);
# first, write the file and time how long it takes
print("Writing file: ", file=sys.stderr)
start = time.time();
gsd.libgsd.gsd_create('test.gsd', 'test', 'test', 1);
file = gsd.libgsd.gsd_open('test.gsd');
write_random_file(file, nframes, N);
gsd.libgsd.gsd_close(file);
end = time.time();
timings['write'] = actual_size / 1024**2 / (end - start);
call(['sudo', '/bin/sync']);
call(['sudo', '/sbin/sysctl', 'vm.drop_caches=3'], stdout=PIPE);
# time how long it takes to open the file
print("Opening file... ", file=sys.stderr, end='')
start = time.time();
file = gsd.libgsd.gsd_open('test.gsd');
end = time.time();
print(end - start, "s", file=sys.stderr);