diff --git a/binarycpython/utils/cache.py b/binarycpython/utils/cache.py index 021f1bcc341fbb3bcdb4ab52a02af6e79ff9a1fe..50dfe03c00455af1f82ab6b4a82635a736bdcf2e 100644 --- a/binarycpython/utils/cache.py +++ b/binarycpython/utils/cache.py @@ -107,7 +107,7 @@ class cache(): else: # function isn't wrapped, which means it was previously # unwrapped, so rewrap it if not using NoCache - if usecachetype != 'NoCache': + if usecachetype != 'NoCache' and func in self.cached_function_cache: _code = 'module.{}.{} = self.cached_function_cache["{}"]'.format(x[0],x[1],func) exec(_code) @@ -216,3 +216,69 @@ class cache(): print('') print("Best cache type {type} with maxsize {maxsize}\n".format(type=best_type,maxsize=best_maxsize)) return + + + """ +Cache speed test of function distribution_functions.powerlaw_constant + 0 1 2 4 8 16 32 64 128 256 +NoCache 6.28e+07 +NullCache 6.39e+07 6.40e+07 6.41e+07 6.39e+07 6.44e+07 6.43e+07 6.37e+07 6.40e+07 6.38e+07 6.40e+07 +FIFOCache 6.41e+07 6.37e+07 6.40e+07 6.39e+07 6.40e+07 6.37e+07 6.41e+07 6.40e+07 6.41e+07 6.40e+07 +LRUCache 6.42e+07 6.41e+07 6.42e+07 6.41e+07 6.38e+07 6.43e+07 6.41e+07 6.43e+07 6.40e+07 6.41e+07 +TTLCache 6.41e+07 6.35e+07 6.37e+07 6.39e+07 6.37e+07 6.42e+07 6.39e+07 6.38e+07 6.37e+07 6.38e+07 +Best cache type NullCache with maxsize 8 + +Cache speed test of function distribution_functions.calculate_constants_three_part_powerlaw + 0 1 2 4 8 16 32 64 128 256 +NoCache 1.44e+07 +NullCache 9.13e+06 9.18e+06 9.20e+06 9.21e+06 9.20e+06 9.12e+06 9.18e+06 9.18e+06 9.15e+06 9.12e+06 +FIFOCache 2.53e+07 2.52e+07 2.51e+07 2.50e+07 2.51e+07 2.52e+07 2.52e+07 2.52e+07 2.52e+07 2.51e+07 +LRUCache 1.62e+07 1.62e+07 1.62e+07 1.62e+07 1.62e+07 1.62e+07 1.62e+07 1.62e+07 1.62e+07 1.62e+07 +TTLCache 1.43e+07 1.43e+07 1.43e+07 1.43e+07 1.43e+07 1.44e+07 1.42e+07 1.43e+07 1.43e+07 1.43e+07 +Best cache type FIFOCache with maxsize 0 + +Cache speed test of function distribution_functions.gaussian_normalizing_const + 0 1 2 4 8 16 32 64 128 256 +NoCache 64183 +NullCache 64340 64339 64544 64260 64491 64382 64400 63974 63954 64338 +FIFOCache 2.62e+07 2.62e+07 2.62e+07 2.61e+07 2.61e+07 2.59e+07 2.61e+07 2.59e+07 2.57e+07 2.59e+07 +LRUCache 1.66e+07 1.66e+07 1.65e+07 1.66e+07 1.65e+07 1.65e+07 1.64e+07 1.65e+07 1.64e+07 1.65e+07 +TTLCache 1.42e+07 1.44e+07 1.42e+07 1.44e+07 1.43e+07 1.43e+07 1.42e+07 1.44e+07 1.42e+07 1.44e+07 +Best cache type FIFOCache with maxsize 1 + +Cache speed test of function spacing_functions.const_linear + 0 1 2 4 8 16 32 64 128 256 +NoCache 1.22e+06 +NullCache 1.05e+06 1.05e+06 1.06e+06 1.05e+06 1.05e+06 1.06e+06 1.05e+06 1.05e+06 1.05e+06 1.05e+06 +FIFOCache 2.85e+07 2.85e+07 2.86e+07 2.85e+07 2.84e+07 2.85e+07 2.84e+07 2.84e+07 2.85e+07 2.81e+07 +LRUCache 1.77e+07 1.79e+07 1.73e+07 1.73e+07 1.76e+07 1.79e+07 1.76e+07 1.74e+07 1.74e+07 1.72e+07 +TTLCache 1.46e+07 1.49e+07 1.50e+07 1.53e+07 1.51e+07 1.53e+07 1.52e+07 1.51e+07 1.47e+07 1.50e+07 +Best cache type FIFOCache with maxsize 2 + +Cache speed test of function spacing_functions.const_int + 0 1 2 4 8 16 32 64 128 256 +NoCache 4.23e+07 +NullCache 1.65e+07 1.66e+07 1.65e+07 1.64e+07 1.66e+07 1.65e+07 1.59e+07 1.59e+07 1.65e+07 1.64e+07 +FIFOCache 2.86e+07 2.86e+07 2.87e+07 2.86e+07 2.84e+07 2.86e+07 2.81e+07 2.79e+07 2.78e+07 2.85e+07 +LRUCache 1.78e+07 1.78e+07 1.77e+07 1.75e+07 1.77e+07 1.78e+07 1.78e+07 1.78e+07 1.74e+07 1.75e+07 +TTLCache 1.55e+07 1.54e+07 1.55e+07 1.54e+07 1.55e+07 1.49e+07 1.52e+07 1.51e+07 1.52e+07 1.54e+07 +Best cache type NoCache with maxsize 0 + +Cache speed test of function spacing_functions.const_ranges + 0 1 2 4 8 16 32 64 128 256 +NoCache 2.54e+05 +NullCache 2.25e+05 2.25e+05 2.24e+05 2.25e+05 2.25e+05 2.25e+05 2.25e+05 2.26e+05 2.25e+05 2.26e+05 +FIFOCache 2.58e+07 2.55e+07 2.53e+07 2.54e+07 2.56e+07 2.57e+07 2.56e+07 2.57e+07 2.58e+07 2.58e+07 +LRUCache 1.62e+07 1.63e+07 1.62e+07 1.62e+07 1.61e+07 1.62e+07 1.62e+07 1.62e+07 1.61e+07 1.63e+07 +TTLCache 1.41e+07 1.43e+07 1.42e+07 1.42e+07 1.40e+07 1.42e+07 1.42e+07 1.43e+07 1.40e+07 1.43e+07 +Best cache type FIFOCache with maxsize 128 + +Cache speed test of function spacing_functions.gaussian_zoom + 0 1 2 4 8 16 32 64 128 256 +NoCache 24703 +NullCache 24872 24935 24927 24896 24968 24964 24882 24840 24873 24913 +FIFOCache 2.54e+07 2.54e+07 2.54e+07 2.54e+07 2.53e+07 2.52e+07 2.53e+07 2.51e+07 2.52e+07 2.52e+07 +LRUCache 1.63e+07 1.63e+07 1.63e+07 1.64e+07 1.63e+07 1.64e+07 1.63e+07 1.63e+07 1.63e+07 1.63e+07 +TTLCache 1.43e+07 1.43e+07 1.42e+07 1.42e+07 1.43e+07 1.42e+07 1.43e+07 1.43e+07 1.43e+07 1.43e+07 +Best cache type FIFOCache with maxsize 0 + """ diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py index b9b0b9c4777bfeb6cf5607b3ce492a5b407f5c5b..71dc78c613118b80121ef7a6c22fcd79dbece558 100644 --- a/binarycpython/utils/grid.py +++ b/binarycpython/utils/grid.py @@ -457,6 +457,7 @@ class Population(analytics, for param_name in sorted(parameter_dict): argline += "{} {} ".format(param_name, parameter_dict[param_name]) argline = argline.strip() + return argline ################################################### @@ -1939,7 +1940,7 @@ class Population(analytics, raise ValueError # Set up the grid code with a dry run option to see total probability - print("Do dry {}".format(self.grid_options["do_dry_run"])) + print("Do dry run? {}".format(self.grid_options["do_dry_run"])) if self.grid_options["do_dry_run"]: print("Doing dry run to calculate total starcount and probability") self._generate_grid_code(dry_run=True) @@ -1949,7 +1950,7 @@ class Population(analytics, self._load_grid_function() # Do a dry run - print("Do dry run") + print("Doing dry run") self._dry_run() self.verbose_print( diff --git a/binarycpython/utils/grid_options_defaults.py b/binarycpython/utils/grid_options_defaults.py index 8f6d66d681e5d1389ae2dcd234ddac032bae94cc..a5a83a4004cf3e853974285e3e57c7f2b4f23a45 100644 --- a/binarycpython/utils/grid_options_defaults.py +++ b/binarycpython/utils/grid_options_defaults.py @@ -183,12 +183,12 @@ class grid_options_defaults(): # # if n is None, no cache is set up "distribution_functions.powerlaw_constant" : (0, "NoCache", "1,100,-2"), - "distribution_functions.calculate_constants_three_part_powerlaw" : (4, None, "0.1,0.5,1,100,-1.3,-2.3,-2.3"), - "distribution_functions.gaussian_normalizing_const" : (0, None, "1.0,1.0,-10.0,+10.0"), - "spacing_functions.const_linear" : (0, None, "1,10,9"), + "distribution_functions.calculate_constants_three_part_powerlaw" : (16, "FIFOCache", "0.1,0.5,1,100,-1.3,-2.3,-2.3"), + "distribution_functions.gaussian_normalizing_const" : (16, "FIFOCache", "1.0,1.0,-10.0,+10.0"), + "spacing_functions.const_linear" : (16, "FIFOCache", "1,10,9"), "spacing_functions.const_int" : (0, None, "1,10,9"), - "spacing_functions.const_ranges" : (0, None, "((0.1,0.65,10),(0.65,0.85,20),(0.85,10.0,10))"), - "spacing_functions.gaussian_zoom" : (0, None, "1.0,10.0,5.0,2.0,0.9,100"), + "spacing_functions.const_ranges" : (16, "FIFOCache", "((0.1,0.65,10),(0.65,0.85,20),(0.85,10.0,10))"), + "spacing_functions.gaussian_zoom" : (16, "FIFOCache", "1.0,10.0,5.0,2.0,0.9,100"), }, ######################################## diff --git a/binarycpython/utils/spacing_functions.py b/binarycpython/utils/spacing_functions.py index a16be46c6dc0799fbe47c31e0804c0819e4c4d6e..bc3d532880aba96d6c2dc994ae562c311b4af711 100644 --- a/binarycpython/utils/spacing_functions.py +++ b/binarycpython/utils/spacing_functions.py @@ -183,9 +183,6 @@ class spacing_functions(): return np.unique(array) - @cachetools.cachedmethod( - lambda self: self.caches["spacing_functions.const_dt"] - ) def const_dt(self,cachedir=None,usecache=True,**kwargs): """ const_dt returns a list of masses spaced at a constant age difference @@ -279,6 +276,7 @@ class spacing_functions(): start_at=0, slurm=0, condor=0, + multiplicity=1, ) # make a grid in M1