Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
timings['open_time'] = (end - start);
# Read the file sequentially and measure the time taken
print("Sequential read file:", file=sys.stderr)
start = time.time();
read_sequential_file(file, nframes, N);
end = time.time();
timings['seq_read'] = actual_size / 1024**2 / (end - start);
# If the size is small, read the file again (cached)
if size < 10*1024**3:
print("Sequential read file: (cached)", file=sys.stderr)
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);