Esempio n. 1
0
 def setup(self):
     if self.names is None:
         self.names = []
     self.add_all = 'all' in self.names
     self.enabled = True
     log_prof.debug("libs: names=%s, all=%s, add_calls=%s", self.names,
                    self.add_all, self.add_calls)
Esempio n. 2
0
 def setup(self):
   if self.names is None:
     self.names = []
   self.add_all = 'all' in self.names
   self.enabled = True
   log_prof.debug("libs: names=%s, all=%s, add_calls=%s",
                  self.names, self.add_all, self.add_calls)
Esempio n. 3
0
 def _save_data(self):
     log_prof.debug("saving profile data to '%s'", self.file)
     df = ProfDataFile()
     # run through profilers and get data
     for name in self.profilers:
         prof = self.profilers[name]
         data = prof.get_data()
         if data:
             df.set_prof_data(name, data)
     df.save_json_file(self.file)
     log_prof.debug("done saving.")
Esempio n. 4
0
 def _save_data(self):
   log_prof.debug("saving profile data to '%s'", self.file)
   df = ProfDataFile()
   # run through profilers and get data
   for name in self.profilers:
     prof = self.profilers[name]
     data = prof.get_data()
     if data:
       df.set_prof_data(name, data)
   df.save_json_file(self.file)
   log_prof.debug("done saving.")
Esempio n. 5
0
 def _try_load_data(self):
     if os.path.exists(self.file):
         log_prof.debug("loading profile data from '%s'", self.file)
         df = ProfDataFile()
         df.load_json_file(self.file)
         # run through profilers and set data
         for name in self.profilers:
             prof = self.profilers[name]
             data = df.get_prof_data(name)
             if data:
                 prof.set_data(ConfigDict(data))
         log_prof.debug("done loading.")
Esempio n. 6
0
 def _try_load_data(self):
   if os.path.exists(self.file):
     log_prof.debug("loading profile data from '%s'", self.file)
     df = ProfDataFile()
     df.load_json_file(self.file)
     # run through profilers and set data
     for name in self.profilers:
       prof = self.profilers[name]
       data = df.get_prof_data(name)
       if data:
         prof.set_data(ConfigDict(data))
     log_prof.debug("done loading.")
Esempio n. 7
0
 def add_profiler(self, prof):
     """add profiler and return if it was activated"""
     # a profile is always disabled if profiling itself is disabled
     if not self.enabled:
         return False
     # get and check name for duplicates
     name = prof.get_name()
     if name in self.profilers:
         raise ValueError("profiler '%s' already exists!" % name)
     # setup config of profiler (if any)
     if self.cfg and name in self.cfg:
         sub_cfg = self.cfg[name]
         if not prof.parse_config(sub_cfg):
             log_prof.warning("skipped profiler '%s'", name)
             return False
     log_prof.debug("added profiler '%s'", name)
     self.profilers[name] = prof
     return True
Esempio n. 8
0
 def add_profiler(self, prof):
   """add profiler and return if it was activated"""
   # a profile is always disabled if profiling itself is disabled
   if not self.enabled:
     return False
   # get and check name for duplicates
   name = prof.get_name()
   if name in self.profilers:
     raise ValueError("profiler '%s' already exists!" % name)
   # setup config of profiler (if any)
   if self.cfg and name in self.cfg:
     sub_cfg = self.cfg[name]
     if not prof.parse_config(sub_cfg):
       log_prof.warn("skipped profiler '%s'", name)
       return False
   log_prof.debug("added profiler '%s'", name)
   self.profilers[name] = prof
   return True
Esempio n. 9
0
 def create_profile(self, lib_name, fd, func_tags=None):
     """get or create a new profile for a library"""
     # profiling disabled
     if not self.enabled:
         log_prof.debug("libs: create '%s' -> disabled", lib_name)
         return None
     # already created profile
     if lib_name in self.lib_profiles:
         log_prof.debug("libs: create '%s' -> reuse", lib_name)
         prof = self.lib_profiles[lib_name]
         prof.setup_func_table(fd, func_tags)
         return prof
     elif self.add_all or lib_name in self.names:
         # shall we create a profile for this lib?
         log_prof.debug("libs: create '%s' -> NEW", lib_name)
         prof = LibProfileData(fd, self.add_calls)
         self.lib_profiles[lib_name] = prof
         return prof
     else:
         log_prof.debug("libs: create '%s' -> not found", lib_name)
Esempio n. 10
0
 def create_profile(self, lib_name, fd, func_tags=None):
   """get or create a new profile for a library"""
   # profiling disabled
   if not self.enabled:
     log_prof.debug("libs: create '%s' -> disabled", lib_name)
     return None
   # already created profile
   if lib_name in self.lib_profiles:
     log_prof.debug("libs: create '%s' -> reuse", lib_name)
     prof = self.lib_profiles[lib_name]
     prof.setup_func_table(fd, func_tags)
     return prof
   elif self.add_all or lib_name in self.names:
     # shall we create a profile for this lib?
     log_prof.debug("libs: create '%s' -> NEW", lib_name)
     prof = LibProfileData(fd, self.add_calls)
     self.lib_profiles[lib_name] = prof
     return prof
   else:
     log_prof.debug("libs: create '%s' -> not found", lib_name)