aboutsummaryrefslogtreecommitdiffstats
path: root/bin/fg21sim
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2016-11-18 10:49:54 +0800
committerAaron LI <aaronly.me@outlook.com>2016-11-18 10:49:54 +0800
commit30867041f9756c451c31fdf83fe35e1fbc9c27ad (patch)
treea6d8d8a08b9d54aabf4955814ecaaca7d5528420 /bin/fg21sim
parenta5d249c0bbe0b3b51930cb23f010a17bdf0dc198 (diff)
downloadfg21sim-30867041f9756c451c31fdf83fe35e1fbc9c27ad.tar.bz2
bin/fg21sim: Import "Foregrounds" when using; Add timing
Diffstat (limited to 'bin/fg21sim')
-rwxr-xr-xbin/fg21sim21
1 files changed, 18 insertions, 3 deletions
diff --git a/bin/fg21sim b/bin/fg21sim
index e605c97..eb45365 100755
--- a/bin/fg21sim
+++ b/bin/fg21sim
@@ -12,9 +12,9 @@ import os
import sys
import argparse
import logging
+import time
-from fg21sim.foregrounds import Foregrounds
-from fg21sim.configs import configs, check_configs
+from fg21sim.configs import configs
from fg21sim.utils import setup_logging
@@ -32,11 +32,14 @@ def main():
help="be quiet so do not log messages to screen")
args = parser.parse_args()
+ t1_start = time.perf_counter()
+ t2_start = time.process_time()
+
configs.read_userconfig(args.config)
if os.environ.get("DEBUG_FG21SIM"):
print("DEBUG: Current configurations:", configs._config,
sep="\n", file=sys.stderr)
- check_configs(configs)
+ configs.check_all()
log_stream = "" if args.quiet else None
setup_logging(dict_config=configs.logging,
@@ -47,11 +50,23 @@ def main():
logger = logging.getLogger(tool)
logger.info("COMMAND: {0}".format(" ".join(sys.argv)))
+ # Save/backup current configurations
+ configfile_dump = os.path.splitext(configs.userconfig)[0] + "_dump.conf"
+ configs.save(configfile_dump, clobber=True, backup=True)
+ logger.info("Saved current configurations to file: %s" % configfile_dump)
+
+ logger.info("Importing modules + Numba JIT, waiting ...")
+ from fg21sim.foregrounds import Foregrounds
fg = Foregrounds(configs)
fg.preprocess()
fg.simulate()
fg.postprocess()
+ t1_stop = time.perf_counter()
+ t2_stop = time.process_time()
+ logger.info("Elapsed time: {0:.3f} (s)".format(t1_stop - t1_start))
+ logger.info("Process time: {0:.3f} (s)".format(t2_stop - t2_start))
+
if __name__ == "__main__":
main()