From 75017f26eb6657130c48921a747e829d02c0a9c3 Mon Sep 17 00:00:00 2001
From: Aaron LI <aly@aaronly.me>
Date: Sun, 4 Feb 2018 15:45:35 +0800
Subject: astro/run_oskar.py: better report time cost

---
 astro/oskar/run_oskar.py | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

(limited to 'astro')

diff --git a/astro/oskar/run_oskar.py b/astro/oskar/run_oskar.py
index 145a083..e2e8653 100755
--- a/astro/oskar/run_oskar.py
+++ b/astro/oskar/run_oskar.py
@@ -68,10 +68,13 @@ def run_oskar(configfile, model, freq, vis_ms, vis_oskar=None,
     if dryrun:
         print("Dry run mode -> DONE!")
     else:
-        t1 = time()
+        tstart = time()
         subprocess.check_call(cmd)
-        t2 = time()
-        print("Elapsed time: %.1f [min]" % ((t2-t1)/60))
+        tcost = time() - tstart
+        if tcost <= 3*60:
+            print("Elapsed time: %.1f [sec]" % tcost)
+        else:
+            print("Elapsed time: %.1f [min]" % (tcost/60))
     print("-------------------------------------------------------------")
 
 
@@ -124,7 +127,7 @@ def main():
                         help="list of sky model items in format of " +
                         "'<freq[MHz]>:<skymodel-file>'")
     args = parser.parse_args()
-    t1 = time()
+    tstart = time()
 
     use_gpus = None
     if args.use_gpu:
@@ -184,9 +187,12 @@ def main():
                   use_gpus=use_gpus, gpu_ids=args.gpu_ids,
                   num_devices=args.num_devices, dryrun=args.dryrun)
 
-    t2 = time()
+    tcost = time() - tstart
     print("=============================================================")
-    print("Total elapsed time: %.1f [min]" % ((t2-t1)/60))
+    if tcost <= 3*60:
+        print("Total elapsed time: %.1f [sec]" % tcost)
+    else:
+        print("Total elapsed time: %.1f [min]" % (tcost/60))
 
 
 if __name__ == "__main__":
-- 
cgit v1.2.2