diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2022-12-22 23:38:42 -0800 |
---|---|---|
committer | Harmen Stoppels <harmenstoppels@gmail.com> | 2022-12-26 22:28:44 +0100 |
commit | be6bb413dfed861c5f317b5d7274e4d47c34aeab (patch) | |
tree | 08771b638cb979dbfcd97b18b95013ece6659391 /lib | |
parent | d23c302ca2e76c4a0f0ab4114d4132febdd1ff18 (diff) | |
download | spack-be6bb413dfed861c5f317b5d7274e4d47c34aeab.tar.gz spack-be6bb413dfed861c5f317b5d7274e4d47c34aeab.tar.bz2 spack-be6bb413dfed861c5f317b5d7274e4d47c34aeab.tar.xz spack-be6bb413dfed861c5f317b5d7274e4d47c34aeab.zip |
`spack solve`: use consistent units for time
`spack solve` is supposed to show you times you can compare. setup, ground, solve, etc.
all in a list. You're also supposed to be able to compare easily across runs. With
`pretty_seconds()` (introduced in #33900), it's easy to miss the units, e.g., spot the
bottleneck here:
```console
> spack solve --timers tcl
setup 22.125ms
load 16.083ms
ground 8.298ms
solve 848.055us
total 58.615ms
```
It's easier to see what matters if these are all in the same units, e.g.:
```
> spack solve --timers tcl
setup 0.0147s
load 0.0130s
ground 0.0078s
solve 0.0008s
total 0.0463s
```
And the units won't fluctuate from run to run as you make changes.
-[x] make `spack solve` timings consistent like before
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/test/util/timer.py | 4 | ||||
-rw-r--r-- | lib/spack/spack/util/timer.py | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/spack/spack/test/util/timer.py b/lib/spack/spack/test/util/timer.py index 16c1564663..9f43526482 100644 --- a/lib/spack/spack/test/util/timer.py +++ b/lib/spack/spack/test/util/timer.py @@ -120,9 +120,9 @@ def test_timer_write(): output = text_buffer.getvalue().splitlines() assert "timer" in output[0] - assert "1.000s" in output[0] + assert "1.0000s" in output[0] assert "total" in output[1] - assert "3.000s" in output[1] + assert "3.0000s" in output[1] deserialized = json.loads(json_buffer.getvalue()) assert deserialized == { diff --git a/lib/spack/spack/util/timer.py b/lib/spack/spack/util/timer.py index 94b0531c16..83d6907c67 100644 --- a/lib/spack/spack/util/timer.py +++ b/lib/spack/spack/util/timer.py @@ -140,11 +140,11 @@ class Timer(object): def write_tty(self, out=sys.stdout): """Write a human-readable summary of timings""" # Individual timers ordered by registration - formatted = [(p, pretty_seconds(self.duration(p))) for p in self.phases] + formatted = [(p, f"{self.duration(p):.4f}s") for p in self.phases] # Total time - formatted.append(("total", pretty_seconds(self.duration()))) + formatted.append(("total", f"{self.duration():.4f}s")) # Write to out for name, duration in formatted: - out.write(" {:10s} {:>10s}\n".format(name, duration)) + out.write(f" {name:10s} {duration:>10s}\n") |