aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2023-01-05 16:26:41 +0100
committerSam James <sam@gentoo.org>2023-01-10 03:28:46 +0000
commit7b47c30537c58c6c9a25b18959c58de85067634d (patch)
treeb6e7048017e4819ac4179b1ad50ffb8526372b88
parentemerge: depgraph: Correctly detect installation from path for binpkgs (diff)
downloadportage-7b47c30537c58c6c9a25b18959c58de85067634d.tar.gz
portage-7b47c30537c58c6c9a25b18959c58de85067634d.tar.bz2
portage-7b47c30537c58c6c9a25b18959c58de85067634d.zip
depgraph: Print dependency resolution time
Print the wall clock time it took emerge to calculate the dependency graph if spinner is used (i.e. we're in verbose mode). Requested-by: Maciej Barć <xgqt@gentoo.org> Signed-off-by: Michał Górny <mgorny@gentoo.org> Closes: https://github.com/gentoo/portage/pull/972 Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r--NEWS4
-rw-r--r--lib/_emerge/depgraph.py6
-rw-r--r--lib/_emerge/stdout_spinner.py1
3 files changed, 11 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index d143765b1..23a652278 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,10 @@
portage-3.0.44 (UNRELEASED)
--------------
+Features:
+* emerge: Show time taken to calculate dependency resolution with
+ emerge --verbose.
+
Bug fixes:
* ebuild: the PATH variable exported to ebuilds has been changed:
The PATH setting from /etc/profile.env is appended to portage-internal
diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
index 4d7a96a2d..15dcfbc84 100644
--- a/lib/_emerge/depgraph.py
+++ b/lib/_emerge/depgraph.py
@@ -6,6 +6,7 @@ import functools
import logging
import stat
import textwrap
+import time
import warnings
import collections
from collections import deque, OrderedDict
@@ -11522,6 +11523,7 @@ def _spinner_start(spinner, myopts):
if show_spinner:
portage.writemsg_stdout("Calculating dependencies ")
+ spinner.start_time = time.time()
def _spinner_stop(spinner):
@@ -11535,6 +11537,10 @@ def _spinner_stop(spinner):
portage.writemsg_stdout("... done!\n")
+ stop_time = time.time()
+ time_fmt = f"{stop_time - spinner.start_time:.2f}"
+ portage.writemsg_stdout(f"Dependency resolution took {darkgreen(time_fmt)} s.\n\n")
+
def backtrack_depgraph(settings, trees, myopts, myparams, myaction, myfiles, spinner):
"""
diff --git a/lib/_emerge/stdout_spinner.py b/lib/_emerge/stdout_spinner.py
index b28977e66..d4c1db59b 100644
--- a/lib/_emerge/stdout_spinner.py
+++ b/lib/_emerge/stdout_spinner.py
@@ -39,6 +39,7 @@ class stdout_spinner:
]
self.last_update = 0
self.min_display_latency = 0.05
+ self.start_time = None
def _return_early(self):
"""