From 91549fbbfd50b75f45de3ed8cb6d2c9f3c728b31 Mon Sep 17 00:00:00 2001
From: Emanuele Aina <emanuele.aina@collabora.com>
Date: Fri, 9 Jul 2021 02:00:22 +0200
Subject: [PATCH] test_urls: Print timings

Signed-off-by: Emanuele Aina <emanuele.aina@collabora.com>
---
 scripts/test_urls.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/scripts/test_urls.py b/scripts/test_urls.py
index 31a825042..1a984259c 100755
--- a/scripts/test_urls.py
+++ b/scripts/test_urls.py
@@ -11,6 +11,7 @@ import sys
 import traceback
 from urllib.parse import urlparse
 import urllib3
+import time
 import fnmatch
 
 EXCLUDE = [
@@ -84,6 +85,7 @@ broken = 0
 for url in urls:
     print("%s : " %(url), end='')
     sys.stdout.flush()
+    start = time.perf_counter()
     status = None
     try:
         resp = requests.head(url, headers=headers, allow_redirects=True, timeout=60, verify=False)
@@ -101,12 +103,11 @@ for url in urls:
             resp.close()
     except Exception as e:
         status = False
+    end = time.perf_counter()
 
-    if status:
-        print("OK")
-    else:
-        print("Fail")
+    if not status:
         broken += 1
+    print(url, "OK" if status else "FAIL", f"{end - start:0.4f}s")
 
 print("Found %d broken URLs in %d tested" %(broken, len(urls)))
 
-- 
GitLab