Nir Soffer has uploaded a new change for review.
Change subject: fc-scan: Replace timing code with utils.stopwatch
......................................................................
fc-scan: Replace timing code with utils.stopwatch
Replace explicit timing code and monotonic_time re-implementation with
new stopwatch contextmanager.
Change-Id: I47d99a21282f605492e4edfef5573efd7ce3779f
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm/storage/fc-scan
1 file changed, 8 insertions(+), 12 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/67/42567/1
diff --git a/vdsm/storage/fc-scan b/vdsm/storage/fc-scan
index 344345d..fe107e8 100755
--- a/vdsm/storage/fc-scan
+++ b/vdsm/storage/fc-scan
@@ -40,6 +40,8 @@
import sys
import threading
+from vdsm import utils
+
log = logging.getLogger("fc-scan")
@@ -62,15 +64,13 @@
try:
path = "/sys/class/scsi_host/%s/scan" % self.host
log.debug("Scanning %s", path)
- start = monotonic_time()
- fd = os.open(path, os.O_WRONLY)
- try:
- os.write(fd, "- - -")
- finally:
- os.close(fd)
+ with utils.stopwatch("Scanned %s" % path, log=log):
+ fd = os.open(path, os.O_WRONLY)
+ try:
+ os.write(fd, "- - -")
+ finally:
+ os.close(fd)
self.succeeded = True
- elapsed = monotonic_time() - start
- log.debug("Scanned %s in %.2f seconds", path, elapsed)
except OSError as e:
log.error("Scanning %s failed: %s", path, e)
except Exception:
@@ -105,10 +105,6 @@
if not all(s.succeeded for s in scans):
return 1
-
-
-def monotonic_time():
- return os.times()[4]
if __name__ == '__main__':
--
To view, visit
https://gerrit.ovirt.org/42567
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I47d99a21282f605492e4edfef5573efd7ce3779f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>