Skip to content
Snippets Groups Projects
Commit ca88a72e authored by Lionel GUEZ's avatar Lionel GUEZ
Browse files

Measure elapsed times

parent 82da37a2
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,8 @@ import shapefile
import sys
from dateutil import parser
import netCDF4
import time
import csv
argparser = argparse.ArgumentParser()
argparser.add_argument("first_file",
......@@ -58,11 +60,17 @@ else:
for orient in ["cyclo", "anti"]:
if os.access(f"SHPC_{orient}_all_dates", os.F_OK):
shutil.rmtree(f"SHPC_{orient}_all_dates")
perf_report = open("perf_report.csv", "w", newline='')
writer = csv.writer(perf_report, lineterminator = "\n")
writer.writerow(["date", "elapsed NCO", "elapsed Fortran", "elapsed cat"])
while True:
print("inst_eddies.py: Date:", my_date)
if os.access(nc_file, os.F_OK):
my_pc = time.perf_counter()
if args.bbox:
xmin, xmax, ymin, ymax = args.bbox
nco_instance.ncks(nc_file, output = "cropped.nc",
......@@ -77,15 +85,21 @@ while True:
os.symlink(nc_file, "uv.nc")
os.mkdir("SHPC_cyclo")
os.mkdir("SHPC_anti")
elapsed_NCO = time.perf_counter() - my_pc
with open("main_nml.txt") as nml_file:
my_pc = time.perf_counter()
subprocess.run(inst_eddies_exe, stdin = nml_file, check = True)
elapsed_Fortran = time.perf_counter() - my_pc
os.remove("h.nc")
os.remove("uv.nc")
else:
print("inst_eddies.py: Missing file:", nc_file)
elapsed_NCO, elapsed_Fortran = - 1, - 1
my_pc = time.perf_counter()
for orient in ["cyclo", "anti"]:
if os.access(f"SHPC_{orient}_all_dates", os.F_OK):
if os.access(f"SHPC_{orient}", os.F_OK):
......@@ -109,10 +123,13 @@ while True:
if os.access(f"SHPC_{orient}", os.F_OK):
os.rename(f"SHPC_{orient}", f"SHPC_{orient}_all_dates")
elapsed_cat = time.perf_counter() - my_pc
writer.writerow([my_date, elapsed_NCO, elapsed_Fortran, elapsed_cat])
my_date += datetime.timedelta(1)
if my_date > last_date: break
basename = my_date.strftime(args.template)
nc_file = path.join(dirname, basename)
perf_report.close()
os.remove("unpacked.nc")
if args.bbox: os.remove("cropped.nc")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment