Ejemplo n.º 1
0
def main():
    # don't make it bigger than 20000, that's a massive array!
    #array_shapes = [10, 20, 50, 100, 200, 500, 1000, 3000, 5000, 10000, 15000, 20000]
    array_shapes = [10, 12, 15, 18, 20, 35, 50, 100, 200, 500, 800, 1000, 1500, 2000, 3162]
    ymax = array_shapes[-1]/25000.0

    results = None
    pypy_results = None
    args = getargs()
    
    laplace_funcs = (('Pure Python (Cpython)', py_laplace.py_run),
                    ('NumPy', np_laplace.np_run),
                    ('Numba', numba_laplace.numba_run),
                    ('Cython', cy_laplace.cy_run),
                    ('Cython C wrapper', cy_wrap_claplace.cy_run_c_wrap),
                    ('Cython parallel', cy_laplace.cy_run_parallel),
                    # ('Numba laplace vectorized', numba_laplace.numba_run_vectorized),
                    )

    if args.timing:
        results = run_all(laplace_funcs, array_shapes, maxtime=ymax)
        
        with open('results.json', 'w') as fp:
            json.dump(results, fp)

    if args.plot:
        if results is None:
            with open('results.json', 'r') as fp:
                results = json.load(fp)
            
            with open('pypy_results.json', 'r') as pypy_fp:
                pypy_results = json.load(pypy_fp)

        plot_results([results, pypy_results], array_shapes[0]**2, array_shapes[-1]**2, 10e-8, ymax)
Ejemplo n.º 2
0
#!/usr/bin/env python
# Running the Pypy laplace demo from a standalone script since 
# it cannot import Cython C extensions, matplotlib, etc.

import json
from run_comparison import run_all
import py_laplace

if __name__ == '__main__':
    array_shapes = [10, 12, 15, 18, 20, 35, 50, 100, 200, 500, 800, 1000, 1500, 2000, 3162]
    laplace_funcs = (('Pure Python (Pypy)', py_laplace.py_run),)
    
    pypy_results = run_all(laplace_funcs, array_shapes)
    
    with open('pypy_results.json', 'w') as fp:
        json.dump(pypy_results[0], fp)