From f4a870594cd92ad3f40ce004370a24b50698f0c5 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Sat, 3 Feb 2018 17:00:09 +0800 Subject: Improve costing time report: use seconds if <= 3 minutes --- fg21sim/foregrounds.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'fg21sim/foregrounds.py') diff --git a/fg21sim/foregrounds.py b/fg21sim/foregrounds.py index cffc3be..a0ef0af 100644 --- a/fg21sim/foregrounds.py +++ b/fg21sim/foregrounds.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016-2017 Weitian LI +# Copyright (c) 2016-2018 Weitian LI # MIT license """ @@ -114,11 +114,15 @@ class Foregrounds: self.products.add_component(compID, skyfiles) comp_obj.postprocess() - t1_stop = time.perf_counter() - t2_stop = time.process_time() + t1_cost = time.perf_counter() - t1_start + t2_cost = time.process_time() - t2_start logger.info("--------------------------------------------------") - logger.info("Elapsed time: %.1f [min]" % ((t1_stop-t1_start)/60)) - logger.info("CPU process time: %.1f [min]" % ((t2_stop-t2_start)/60)) + if t1_cost <= 3*60: + logger.info("Elapsed time: %.1f [sec]" % t1_cost) + logger.info("CPU process time: %.1f [sec]" % t2_cost) + else: + logger.info("Elapsed time: %.1f [min]" % (t1_cost/60)) + logger.info("CPU process time: %.1f [min]" % (t2_cost/60)) logger.info("--------------------------------------------------") def simulate(self): @@ -136,7 +140,11 @@ class Foregrounds: logger.info(">>> Time usage <<<") logger.info("==================================================") for compID, t1, t2 in timers: - logger.info("%s : %.1f [min]" % (compID, (t2-t1)/60)) + t_cost = t2 - t1 + if t_cost <= 3*60: + logger.info("%s : %.1f [sec]" % (compID, t_cost)) + else: + logger.info("%s : %.1f [min]" % (compID, t_cost/60)) logger.info("--------------------------------------------------") def postprocess(self): -- cgit v1.2.2