4545import os
4646import sys
4747import math
48- import time
49- import functools
5048
5149from logging import Logger
5250from typing import Optional
5755from ..Model .lbsRank import Rank
5856from ..Model .lbsObject import Object
5957
60- def timer (method ):
61- @functools .wraps (method )
62- def wrapper (self , * args , ** kwargs ):
63- start = time .time ()
64- res = method (self , * args , ** kwargs )
65- end = time .time ()
66- dur = end - start
67- self ._VTDataWriter__logger .info (f"{ method .__name__ } : { dur :.4f} s" )
68- return res
69- return wrapper
58+ from ..Utils .lbsTimerDecorator import timer
7059
7160class VTDataWriter :
7261 """A class to write load directives for VT as JSON files
@@ -404,26 +393,13 @@ def _json_writer(self, rank_phases_double) -> str:
404393 @timer
405394 def write (self , phases : dict ):
406395 """ Write one JSON per rank for dictonary of phases with possibly iterations."""
407-
408- ## REGION A
409-
410- # start = time.time()
411-
412396 # Ensure that provided phase has correct type
413397 if not isinstance (phases , dict ):
414398 self .__logger .error (
415399 "JSON writer must be passed a dictionary" )
416400 raise SystemExit (1 )
417401 self .__phases = phases
418402
419- # end = time.time()
420- # dur = end - start
421- # print(f"Region A: {dur} s")
422-
423- ## REGION B
424-
425- # start = time.time()
426-
427403 # Assemble mapping from ranks to their phases
428404 self .__rank_phases = {}
429405 for phase in self .__phases .values ():
@@ -435,27 +411,7 @@ def write(self, phases: dict):
435411 # Prevent recursion overruns
436412 sys .setrecursionlimit (25000 )
437413
438- # end = time.time()
439- # dur = end - start
440- # print(f"Region B: {dur} s")
441-
442- ## REGION C
443-
444- # start = time.time()
445-
446- # Write individual rank files using data parallelism
447- # with mp.pool.Pool(context=mp.get_context("spawn")) as pool:
448- # self.__logger.info(f"{pool._processes} threads for {len(self.__rank_phases)} ranks.")
449- # results = pool.imap_unordered(
450- # self._json_writer, self.__rank_phases.items())
451- # for file_name in results:
452- # self.__logger.info(f"Wrote {file_name}")
453-
454- # Try in serial
414+ # Write individual rank files
455415 for rank_phases_double in self .__rank_phases .items ():
456416 file_name = self ._json_writer (rank_phases_double )
457417 self .__logger .info (f"Wrote { file_name } " )
458-
459- # end = time.time()
460- # dur = end - start
461- # print(f"Region C: {dur} s")
0 commit comments