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
This commit is contained in:
		
				
					committed by
					
						
						Harmen Stoppels
					
				
			
			
				
	
			
			
			
						parent
						
							d23c302ca2
						
					
				
				
					commit
					be6bb413df
				
			@@ -120,9 +120,9 @@ def test_timer_write():
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    output = text_buffer.getvalue().splitlines()
 | 
					    output = text_buffer.getvalue().splitlines()
 | 
				
			||||||
    assert "timer" in output[0]
 | 
					    assert "timer" in output[0]
 | 
				
			||||||
    assert "1.000s" in output[0]
 | 
					    assert "1.0000s" in output[0]
 | 
				
			||||||
    assert "total" in output[1]
 | 
					    assert "total" in output[1]
 | 
				
			||||||
    assert "3.000s" in output[1]
 | 
					    assert "3.0000s" in output[1]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    deserialized = json.loads(json_buffer.getvalue())
 | 
					    deserialized = json.loads(json_buffer.getvalue())
 | 
				
			||||||
    assert deserialized == {
 | 
					    assert deserialized == {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -140,11 +140,11 @@ def write_json(self, out=sys.stdout):
 | 
				
			|||||||
    def write_tty(self, out=sys.stdout):
 | 
					    def write_tty(self, out=sys.stdout):
 | 
				
			||||||
        """Write a human-readable summary of timings"""
 | 
					        """Write a human-readable summary of timings"""
 | 
				
			||||||
        # Individual timers ordered by registration
 | 
					        # 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
 | 
					        # Total time
 | 
				
			||||||
        formatted.append(("total", pretty_seconds(self.duration())))
 | 
					        formatted.append(("total", f"{self.duration():.4f}s"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Write to out
 | 
					        # Write to out
 | 
				
			||||||
        for name, duration in formatted:
 | 
					        for name, duration in formatted:
 | 
				
			||||||
            out.write("    {:10s} {:>10s}\n".format(name, duration))
 | 
					            out.write(f"    {name:10s} {duration:>10s}\n")
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user