Esempio n. 1
0
def benchmark(size, label, results):
    reference = "r_mfilter_reference_map"
    output = "benchmark_r_mfilter_nprocs"
    filter = tempfile()
    with open(filter, "w") as w:
        w.write(
            """MATRIX 9
                   1 1 1 1 1 1 1 1 1
                   1 2 1 2 1 2 1 2 1
                   1 1 3 1 3 1 3 1 1
                   1 2 1 4 1 4 1 2 1
                   1 1 3 1 5 1 3 1 1
                   1 2 1 4 1 4 1 2 1
                   1 1 3 1 3 1 3 1 1
                   1 2 1 2 1 2 1 2 1
                   1 1 1 1 1 1 1 1 1
                   DIVISOR 81
                   TYPE    P"""
        )

    generate_map(rows=size, cols=size, fname=reference)
    module = Module(
        "r.mfilter",
        input=reference,
        output=output,
        filter=filter,
        run_=False,
        stdout_=DEVNULL,
        overwrite=True,
    )
    results.append(bm.benchmark_nprocs(module, label=label, max_nprocs=16, repeat=3))
    Module("g.remove", quiet=True, flags="f", type="raster", name=reference)
    Module("g.remove", quiet=True, flags="f", type="raster", name=output)
Esempio n. 2
0
def benchmark(size, label, results):
    reference = "r_slope_aspect_reference_map"
    slope = "benchmark_slope"
    aspect = "benchmark_aspect"
    pcurv = "benchmark_pcurv"
    tcurv = "benchmark_tcurv"

    generate_map(rows=size, cols=size, fname=reference)
    module = Module(
        "r.slope.aspect",
        elevation=reference,
        slope=slope,
        aspect=aspect,
        pcurvature=pcurv,
        tcurvature=tcurv,
        run_=False,
        stdout_=DEVNULL,
        overwrite=True,
    )
    results.append(
        bm.benchmark_nprocs(module, label=label, max_nprocs=16, repeat=3))
    Module("g.remove", quiet=True, flags="f", type="raster", name=reference)
    Module("g.remove", quiet=True, flags="f", type="raster", name=slope)
    Module("g.remove", quiet=True, flags="f", type="raster", name=aspect)
    Module("g.remove", quiet=True, flags="f", type="raster", name=pcurv)
    Module("g.remove", quiet=True, flags="f", type="raster", name=tcurv)
def benchmark(memory, label, results, reference):

    slope = "benchmark_slope"
    aspect = "benchmark_aspect"
    pcurv = "benchmark_pcurv"
    tcurv = "benchmark_tcurv"

    module = Module(
        "r.slope.aspect",
        elevation=reference,
        slope=slope,
        aspect=aspect,
        pcurvature=pcurv,
        tcurvature=tcurv,
        run_=False,
        stdout_=DEVNULL,
        overwrite=True,
    )
    results.append(
        bm.benchmark_nprocs(module, label=label, max_nprocs=20, repeat=10))

    Module("g.remove", quiet=True, flags="f", type="raster", name=slope)
    Module("g.remove", quiet=True, flags="f", type="raster", name=aspect)
    Module("g.remove", quiet=True, flags="f", type="raster", name=pcurv)
    Module("g.remove", quiet=True, flags="f", type="raster", name=tcurv)
Esempio n. 4
0
def benchmark(memory, label, results, reference):
    output = "benchmark_r_neighbors_nprocs"

    module = Module(
        "r.neighbors",
        input=reference,
        output=output,
        size=9,
        memory=memory,
        run_=False,
        stdout_=DEVNULL,
        overwrite=True,
    )
    results.append(bm.benchmark_nprocs(module, label=label, max_nprocs=16, repeat=3))
    Module("g.remove", quiet=True, flags="f", type="raster", name=output)
Esempio n. 5
0
def benchmark(memory, label, results, reference):
    output = "benchmark_r_series"

    module = Module(
        "r.series",
        input=[reference] * 8,
        output=output,
        method="sum",
        run_=False,
        stdout_=DEVNULL,
        overwrite=True,
        memory=memory,
    )
    results.append(
        bm.benchmark_nprocs(module, label=label, max_nprocs=16, repeat=3))

    Module("g.remove", quiet=True, flags="f", type="raster", name=output)
Esempio n. 6
0
def benchmark(size, label, results):
    references = ["r_patch_reference_map_{}".format(i) for i in range(4)]
    output = "benchmark_r_patch"

    generate_map(rows=size, cols=size, fname=references)
    module = Module(
        "r.patch",
        input=references,
        output=output,
        run_=False,
        stdout_=DEVNULL,
        overwrite=True,
    )
    results.append(
        bm.benchmark_nprocs(module, label=label, max_nprocs=24, repeat=3))
    for r in references:
        Module("g.remove", quiet=True, flags="f", type="raster", name=r)
    Module("g.remove", quiet=True, flags="f", type="raster", name=output)
Esempio n. 7
0
def benchmark(size, label, results):
    reference = "r_series_reference_map"
    output = "benchmark_r_series"

    generate_map(rows=size, cols=size, fname=reference)
    module = Module(
        "r.series",
        input=[reference] * 8,
        output=output,
        method="sum",
        run_=False,
        stdout_=DEVNULL,
        overwrite=True,
    )
    results.append(
        bm.benchmark_nprocs(module, label=label, max_nprocs=16, repeat=3))
    Module("g.remove", quiet=True, flags="f", type="raster", name=reference)
    Module("g.remove", quiet=True, flags="f", type="raster", name=output)
def benchmark(size, label, results):
    reference = "r_neighbors_reference_map"
    output = "benchmark_r_neighbors_nprocs"

    generate_map(rows=size, cols=size, fname=reference)
    module = Module(
        "r.neighbors",
        input=reference,
        output=output,
        size=9,
        memory=300,
        run_=False,
        stdout_=DEVNULL,
        overwrite=True,
    )
    results.append(
        bm.benchmark_nprocs(module, label=label, max_nprocs=16, repeat=3))
    Module("g.remove", quiet=True, flags="f", type="raster", name=reference)
    Module("g.remove", quiet=True, flags="f", type="raster", name=output)
Esempio n. 9
0
 def test_plot_nprocs_workflow(self):
     """Test that plot nprocs workflow runs"""
     label = "Standard output"
     repeat = 4
     # The benchmark part has only Python API, not CLI.
     try:
         result = benchmark_nprocs(
             module=Module("r.univar",
                           map="elevation",
                           stdout_=DEVNULL,
                           run_=False),
             label=label,
             repeat=repeat,
             max_nprocs=3,
         )
     except grass.exceptions.ParameterError:
         self.skipTest("r.univar without nprocs parameter")
     save_results_to_file([result], self.json_filename)
     benchmark_main(
         ["plot", "nprocs", self.json_filename, self.png_filename1])
     self.assertTrue(Path(self.png_filename1).is_file())