MCPcopy Create free account
hub / github.com/DedalusProject/dedalus / dump_profiles

Method dump_profiles

dedalus/core/solvers.py:780–806  ·  view source on GitHub ↗

Save profiling data to disk.

(self, profiler, name)

Source from the content-addressed store, hash-verified

778 logger.info(f"Timings unavailable because warmup did not complete.")
779
780 def dump_profiles(self, profiler, name):
781 "Save profiling data to disk."
782 comm = self.dist.comm
783 # Disable and create stats on each process
784 profiler.create_stats()
785 p = pstats.Stats(profiler)
786 p.strip_dirs()
787 # Gather using wrapper class to avoid pickling issues
788 profiles = comm.gather(ProfileWrapper(p.stats), root=0)
789 # Sum stats on root process
790 if comm.rank == 0:
791 if self.parallel_profile:
792 stats = {'primcalls': defaultdict(list),
793 'totcalls': defaultdict(list),
794 'tottime': defaultdict(list),
795 'cumtime': defaultdict(list)}
796 for profile in profiles:
797 for func, (primcalls, totcalls, tottime, cumtime, callers) in profile.stats.items():
798 stats['primcalls'][func].append(primcalls)
799 stats['totcalls'][func].append(totcalls)
800 stats['tottime'][func].append(tottime)
801 stats['cumtime'][func].append(cumtime)
802 pickle.dump(stats, open(PROFILE_DIRECTORY / f"{name}_parallel.pickle", 'wb'))
803 # Creation of joint_stats destroys profiles, so do this second
804 joint_stats = pstats.Stats(*profiles)
805 joint_stats.dump_stats(PROFILE_DIRECTORY / f"{name}.prof")
806 comm.Barrier()

Callers 2

stepMethod · 0.95
log_statsMethod · 0.95

Calls 3

ProfileWrapperClass · 0.85
create_statsMethod · 0.80
gatherMethod · 0.45

Tested by

no test coverage detected