forked from spack/spack
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding save of build times on install
Here we are adding an install_times.json into the spack install metadata folder. We record a total, global time, along with the times for each phase. The type of phase or install start / end is included (e.g., build or fail) Signed-off-by: vsoch <vsoch@users.noreply.github.com>
- Loading branch information
Showing
7 changed files
with
151 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other | ||
# Spack Project Developers. See the top-level COPYRIGHT file for details. | ||
# | ||
# SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
|
||
"""Debug signal handler: prints a stack trace and enters interpreter. | ||
``register_interrupt_handler()`` enables a ctrl-C handler that prints | ||
a stack trace and drops the user into an interpreter. | ||
""" | ||
import spack.util.spack_json as sjson | ||
import time | ||
import sys | ||
|
||
|
||
class Timer(object): | ||
""" | ||
Simple timer for timing phases of a solve or install | ||
""" | ||
def __init__(self): | ||
self.start = time.time() | ||
self.last = self.start | ||
self.phases = {} | ||
self.end = None | ||
|
||
def phase(self, name): | ||
last = self.last | ||
now = time.time() | ||
self.phases[name] = now - last | ||
self.last = now | ||
|
||
@property | ||
def total(self): | ||
"""Return the total time | ||
""" | ||
if self.end: | ||
return self.end - self.start | ||
return time.time() - self.start | ||
|
||
def stop(self): | ||
""" | ||
Stop the timer to record a total time, if desired. | ||
""" | ||
self.end = time.time() | ||
|
||
def write_json(self, out=sys.stdout): | ||
""" | ||
Write a json object with times to file | ||
""" | ||
phases = [{"name": p, "seconds": s} for p, s in self.phases.items()] | ||
times = {"phases": phases, "total": {"seconds": self.total}} | ||
out.write(sjson.dump(times)) | ||
|
||
def write_tty(self, out=sys.stdout): | ||
now = time.time() | ||
out.write("Time:\n") | ||
for phase, t in self.phases.items(): | ||
out.write(" %-15s%.4f\n" % (phase + ":", t)) | ||
out.write("Total: %.4f\n" % (now - self.start)) |
30 changes: 30 additions & 0 deletions
30
var/spack/repos/builtin.mock/packages/dev-build-test-install-phases/package.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other | ||
# Spack Project Developers. See the top-level COPYRIGHT file for details. | ||
# | ||
# SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
|
||
from time import sleep | ||
|
||
|
||
class DevBuildTestInstallPhases(Package): | ||
homepage = "example.com" | ||
url = "fake.com" | ||
|
||
version('0.0.0', sha256='0123456789abcdefgh') | ||
|
||
phases = ['one', 'two', 'three', 'install'] | ||
|
||
def one(self, spec, prefix): | ||
sleep(1) | ||
print("One locomoco") | ||
|
||
def two(self, spec, prefix): | ||
sleep(2) | ||
print("Two locomoco") | ||
|
||
def three(self, spec, prefix): | ||
sleep(3) | ||
print("Three locomoco") | ||
|
||
def install(self, spec, prefix): | ||
print("install") |