Skip to content

Commit

Permalink
hwgraph: Add option to manage missing data points.
Browse files Browse the repository at this point in the history
As reported in issue #40, when data points are missing,
hwgraph was crashing because graphs must have the same
number of data points.

In such case, let's default to a fatal message to the user instead of
crahsing.

This commit also add a new hwgraph option, --ignore-missing-datapoint
that can be used to define a behavior to ignore this case and graph.

  --ignore-missing-datapoint=zero will replace the missing datapoint by a 0 value.
  --ignore-missing-datapoint=last will replace the missing datapoint by the last known value of the serie.

It's up to the user to decide which one is the best but also understand
that graphs will be partially wrong.

By default, hwgraph generates a fatal error.

Signed-off-by: Erwan Velu <[email protected]>
  • Loading branch information
ErwanAliasr1 committed Oct 25, 2024
1 parent 3084817 commit f8c8e15
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
25 changes: 24 additions & 1 deletion graph/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,30 @@ def generic_graph(
for component in components:
if component.get_full_name() not in data_serie:
data_serie[component.get_full_name()] = []
data_serie[component.get_full_name()].append(component.get_mean()[sample])
# If we are missing some datapoints ....
if len(component.get_mean()) <= sample:
# If the user didn't explictely agreed to be replaced by 0, let's be fatal
if not args.ignore_missing_datapoint:
fatal(
f"{trace.get_name()}/{bench.get_bench_name()}: {component.get_full_name()} is missing the {sample+1}th data point.\
Use --ignore-missing-datapoint to ignore this case. Generated graphs will be partially incorrect."
)
else:
# User is fine with a missing data to be replaced.
# Let's do that so we can render things properly.

# Let's pick the last known value
if args.ignore_missing_datapoint == "last":
data_serie[component.get_full_name()].append(
component.get_mean()[-1]
)
else:
# Replace it by a zero
data_serie[component.get_full_name()].append(0)
else:
data_serie[component.get_full_name()].append(
component.get_mean()[sample]
)

if second_axis:
for _, entry in bench.get_monitoring_metric(second_axis).items():
Expand Down
7 changes: 7 additions & 0 deletions graph/hwgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,13 @@ def main():
action="store_true",
help="Enable verbose mode",
)

parser_graph.add_argument(
"--ignore-missing-datapoint",
choices=["zero", "last"],
default="",
help="Replace a missing datapoint instead of stopping the rendering. Could be by a zero or the last known value.",
)
parser_graph.set_defaults(func=render_traces)

parser_list = subparsers.add_parser(
Expand Down

0 comments on commit f8c8e15

Please sign in to comment.