Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions src/dvsim/testplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,31 @@


class Result:
"""The results for a single test."""
"""The results for a job."""

def __init__(self, name, passing=0, total=0, job_runtime=None, simulated_time=None) -> None:
def __init__(
self,
name: str,
passing: int = 0,
total: int = 0,
job_runtime: float | None = None,
simulated_time: float | None = None,
) -> None:
Comment on lines +21 to +28
Copy link
Copy Markdown
Contributor

@AlexJones0 AlexJones0 May 21, 2026

Choose a reason for hiding this comment

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

One suggestion I might have would be to make most of the arguments here keyword-only:

Suggested change
def __init__(
self,
name: str,
passing: int = 0,
total: int = 0,
job_runtime: float | None = None,
simulated_time: float | None = None,
) -> None:
def __init__(
self,
name: str,
*
passing: int = 0,
total: int = 0,
job_runtime: float | None = None,
simulated_time: float | None = None,
) -> None:

This is because currently you can make a Result like:

Result("example test", 3, 5, 19.20, 13.41)

which isn't particularly descriptive to read, so you need to search through the definition. This change would instead mean you need to write:

Result("example test", passing=3, total=5, job_runtime=19.20, simulated_time=13.41)

I'll leave it up to you whether you prefer that or not though.

"""Construct a Result with the given parameters.

Args:
name: The name of the test.

passing: The number of runs that passed (possibly different seeds).

total: The number of runs that happened (will be at least as large as
passing).
Comment on lines +36 to +37
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Another nice idea might be to add setters for passing and total to this class to enforce this invariant and error otherwise - but I appreciate that's probably outside of the scope of the improvements in this PR, which is just doing some cleanup.


job_runtime: If not None, the number of seconds taken by the job.

simulated_time: If not None, the simulated time in microseconds.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It doesn't need to be changed in this PR (as I appreciate it would be a widespread change across the code base) - but IMO these parameters should be suffixed by their units (e.g. job_runtime_s and simulated_time_us) to avoid the confusion entirely.


"""
self.name = name
self.passing = passing
self.total = total
Expand Down
Loading