-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mapping,constraint,mesh A,mesh B,ranks A,ranks B,computeMappingTime,globalTime,initializeTime,mapDataTime,peakMemA,peakMemB | ||
nn,consistent,coarse_mesh,fine_mesh,2,2,968.0,117537.33333333333,89569.66666666667,1.6666666666666667,116752.0,116426.66666666667 | ||
tps,consistent,coarse_mesh,fine_mesh,2,2,316.6666666666667,143683.0,115327.33333333333,483.6666666666667,115870.66666666667,129608.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!python3 | ||
|
||
import argparse | ||
import pathlib | ||
|
||
import numpy as np | ||
import polars as pl | ||
|
||
|
||
def parseArguments(): | ||
parser = argparse.ArgumentParser( | ||
description="Aggregates statistics of multiple runs. See mapping-tester repreat.py" | ||
) | ||
parser.add_argument( | ||
"file", | ||
type=pathlib.Path, | ||
help="Statistics file to aggregate runs on", | ||
) | ||
parser.add_argument( | ||
"kind", | ||
choices=["mean", "median", "variance"], | ||
help="Kind of aggregation", | ||
) | ||
parser.add_argument( | ||
"-x", | ||
"--exclude-min-max", | ||
dest="exclude", | ||
action="store_true", | ||
help="Remove min and max from the data set before aggregating.", | ||
) | ||
parser.add_argument( | ||
"--output", | ||
"-o", | ||
default="aggregated.csv", | ||
type=pathlib.Path, | ||
help="Statistics file write the aggregated results to.", | ||
) | ||
return parser.parse_args() | ||
|
||
|
||
def trim(series: pl.Series): | ||
return series.sort()[1:-1] | ||
|
||
|
||
def run(file: pathlib.Path, kind: str, exclude: bool, dest: pathlib.Path): | ||
|
||
df = pl.read_csv(file).drop("run") | ||
|
||
# returns a lambda that creates a pl.Exception for a given column name | ||
func = { | ||
"median": lambda c: pl.col(c).median(), | ||
"mean": lambda c: ( | ||
pl.col(c).map_batches(trim).mean() if exclude else pl.col(c).mean() | ||
), | ||
"variance": lambda c: ( | ||
pl.col(c).map_batches(trim).var() if exclude else pl.col(c).var() | ||
), | ||
}[kind] | ||
|
||
case = ["mapping", "constraint", "mesh A", "mesh B", "ranks A", "ranks B"] | ||
df = df.group_by(case).agg([func(c) for c in df.columns if c not in case]) | ||
|
||
print(f"Writing output to {dest}") | ||
df.write_csv(dest) | ||
|
||
|
||
def main(): | ||
args = parseArguments() | ||
assert args.file.exists() | ||
run(args.file, args.kind, args.exclude, args.output) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |