aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2018-02-03 17:00:09 +0800
committerAaron LI <aly@aaronly.me>2018-02-03 17:00:09 +0800
commitf4a870594cd92ad3f40ce004370a24b50698f0c5 (patch)
tree406736bfa721d27af628aaf6cd2a880279f8d654
parentdd54669aec9843b5d4808bfd0cd26da325e914d5 (diff)
downloadfg21sim-f4a870594cd92ad3f40ce004370a24b50698f0c5.tar.bz2
Improve costing time report: use seconds if <= 3 minutes
-rwxr-xr-xbin/fg21sim12
-rw-r--r--fg21sim/foregrounds.py20
-rw-r--r--fg21sim/webui/handlers/console.py12
3 files changed, 30 insertions, 14 deletions
diff --git a/bin/fg21sim b/bin/fg21sim
index eb56df4..3362888 100755
--- a/bin/fg21sim
+++ b/bin/fg21sim
@@ -76,10 +76,14 @@ def main():
fg.simulate()
fg.postprocess()
- t1_stop = time.perf_counter()
- t2_stop = time.process_time()
- logger.info("Elapsed time: %.1f [min]" % ((t1_stop-t1_start)/60))
- logger.info("CPU process time: %.1f [min]" % ((t2_stop-t2_start)/60))
+ t1_cost = time.perf_counter() - t1_start
+ t2_cost = time.process_time() - t2_start
+ 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))
if __name__ == "__main__":
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 <weitian@aaronly.me>
+# Copyright (c) 2016-2018 Weitian LI <weitian@aaronly.me>
# 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):
diff --git a/fg21sim/webui/handlers/console.py b/fg21sim/webui/handlers/console.py
index caf69e3..31689dd 100644
--- a/fg21sim/webui/handlers/console.py
+++ b/fg21sim/webui/handlers/console.py
@@ -183,10 +183,14 @@ class ConsoleAJAXHandler(BaseRequestHandler):
fg.postprocess()
logger.info("Foregrounds simulations DONE!")
logger.info("Console DEFAULT task: DONE!")
- t1_stop = time.perf_counter()
- t2_stop = time.process_time()
- logger.info("Elapsed time: {0:.3f} (s)".format(t1_stop - t1_start))
- logger.info("CPU process time: {0:.3f} (s)".format(t2_stop - t2_start))
+ t1_cost = time.perf_counter() - t1_start
+ t2_cost = time.process_time() - t2_start
+ 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))
# NOTE: always return a tuple of (success, error)
return (True, None)