How to use the gsd.libgsd.gsd_close function in gsd

To help you get started, we’ve selected a few gsd examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github glotzerlab / gsd / test / benchmark_gsd.py View on Github external
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);

    timings['open_time'] = (end - start);
github glotzerlab / gsd / test / benchmark_gsd.py View on Github external
end = time.time();

        timings['seq_cache_read'] = actual_size / 1024**2 / (end - start);
    else:
        timings['seq_cache_read'] = 0;

    # Read the file randomly and measure the time taken
    print("Random read file:", file=sys.stderr)
    start = time.time();
    read_random_file(file, nframes, N);
    end = time.time();

    timings['random_read'] = actual_size / 1024**2 / (end - start);
    timings['random_read_time'] = (end - start) / nframes / 1e-3;

    gsd.libgsd.gsd_close(file);
    os.unlink('test.gsd')
    return timings