Skip to content

Add numeric elapsed_seconds to metrics JSON - #3943

Merged
maliberty merged 3 commits into
The-OpenROAD-Project:masterfrom
harsh-kumar-patwa:add-elapsed-seconds-to-metrics
Mar 3, 2026
Merged

maliberty merged 3 commits into
The-OpenROAD-Project:masterfrom
harsh-kumar-patwa:add-elapsed-seconds-to-metrics

Conversation

@harsh-kumar-patwa

Copy link
Copy Markdown
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 thread flow/util/genMetrics.py
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
Copy Markdown
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.

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

Copy link
Copy Markdown
Contributor Author

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
@maliberty
maliberty disabled auto-merge March 3, 2026 22:24
@maliberty
maliberty merged commit 072c898 into The-OpenROAD-Project:master Mar 3, 2026
5 checks passed
@maliberty

Copy link
Copy Markdown
Member

The failure looks unrelated

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