How to use the gsd.libgsd.gsd_create 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);