Skip to content

Add numeric elapsed_seconds to metrics JSON#3943

Open
harsh-kumar-patwa wants to merge 3 commits intoThe-OpenROAD-Project:masterfrom
harsh-kumar-patwa:add-elapsed-seconds-to-metrics
Open

Add numeric elapsed_seconds to metrics JSON#3943
harsh-kumar-patwa wants to merge 3 commits intoThe-OpenROAD-Project:masterfrom
harsh-kumar-patwa:add-elapsed-seconds-to-metrics

Conversation

@harsh-kumar-patwa
Copy link
Contributor

Summary

Resolves #2506

genMetrics.py stores stage runtimes as human-readable strings (e.g., "0:04.26") in the metrics JSON. This makes them hard to consume programmatically — users have to parse the time format manually for analysis, plotting, or comparison.

This adds numeric elapsed_seconds fields (float, in seconds) alongside the existing string fields, so runtimes are directly usable as numbers.

Changes

flow/util/genMetrics.py

  • In the existing runtime accumulation loop, compute delta.total_seconds() for each stage and store as <stage>__elapsed_seconds
  • Add total_elapsed_seconds alongside the existing total_time string

Example output (new fields only)

{
  "synth__runtime__total": "0:00.90",
  "synth__elapsed_seconds": 0.9,
  "globalplace__runtime__total": "0:02.59",
  "globalplace__elapsed_seconds": 2.59,
  "total_time": "0:00:18.900000",
  "total_elapsed_seconds": 18.9
}

Existing fields (__runtime__total, total_time, __cpu__total, __mem__peak) are unchanged. The hierarchical JSON format (-x flag) also works correctly since the new keys follow the same stage__metric naming convention.

Resolves The-OpenROAD-Project#2506

genMetrics.py stores stage runtimes as human-readable strings
(e.g., "0:04.26") which are hard to consume programmatically.
This adds numeric elapsed_seconds fields (in seconds as floats)
alongside the existing string fields so runtimes are directly
usable for analysis and plotting.

New fields added per stage:
  - <stage>__elapsed_seconds (float, seconds)
  - total_elapsed_seconds (float, seconds)

Existing fields (runtime__total, total_time) are unchanged.

Signed-off-by: Harsh Kumar Patwa <harshkumarpatwa@gmail.com>
Signed-off-by: Harsh Kumar <harshkumar3446@gmail.com>
Comment on lines 348 to +352
if failed:
metrics_dict["total_time"] = "ERR"
else:
metrics_dict["total_time"] = str(total)
metrics_dict["total_elapsed_seconds"] = total.total_seconds()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the failed case it would make sense to have total_elapsed_seconds = ERR too for consistency.

Copy link
Contributor Author

@harsh-kumar-patwa harsh-kumar-patwa Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, fixed ! added total_elapsed_seconds = "ERR" in the failed case. Thanks!

Address review feedback: add total_elapsed_seconds = "ERR" in
the failed parsing case for consistency with total_time.

Signed-off-by: Harsh Kumar Patwa <harshkumarpatwa@gmail.com>
Signed-off-by: Harsh Kumar <harshkumar3446@gmail.com>
@maliberty maliberty enabled auto-merge March 2, 2026 18:37
str.removesuffix() requires Python 3.9+. Replace with a
string slice to maintain compatibility with older Python
versions used in CI.

Signed-off-by: Harsh Kumar Patwa <harshkumarpatwa@gmail.com>
Signed-off-by: Harsh Kumar <harshkumar3446@gmail.com>
auto-merge was automatically disabled March 2, 2026 20:30

Head branch was pushed to by a user without write access

@maliberty maliberty enabled auto-merge March 2, 2026 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add running times to .json files

2 participants