def libcore_profiler_profiler_reuse_test(): name = 'dos.library' fd = read_lib_fd(name) prof = LibProfiler() prof.parse_config(ConfigDict({ "names": [name], "calls": True })) prof.setup() p = prof.create_profile(name, fd) assert p f = p.get_func_by_name("Input") assert f idx = f.get_func_id() assert p.get_func_by_index(idx) == f f.count(1.0) # store/restore data = prof.get_data() prof2 = LibProfiler() assert prof2.set_data(data) prof2.setup() # reuse profile p2 = prof2.create_profile(name, fd) assert p == p2 f2 = p2.get_func_by_name("Input") assert f2.get_num_calls() == 1 f2.count(1.0) assert f2.get_num_calls() == 2 idx = f2.get_func_id() assert p2.get_func_by_index(idx) == f2
def libcore_profiler_profiler_set_get_data_test(): name = 'dos.library' fd = read_lib_fd(name) prof = LibProfiler(names=[name]) prof.setup() p = prof.create_profile(name, fd) data = prof.get_data() prof2 = LibProfiler() assert prof2.set_data(data) p2 = prof2.get_profile(name) assert p == p2
def libcore_profiler_profiler_config_test(): name = 'dos.library' fd = read_lib_fd(name) prof = LibProfiler() prof.parse_config(ConfigDict({"names": [name], "calls": True})) prof.setup() p = prof.create_profile(name, fd) data = prof.get_data() prof2 = LibProfiler() assert prof2.set_data(data) p2 = prof2.get_profile(name) assert p == p2
def libcore_profiler_main_profiler_test(): name = 'dos.library' fd = read_lib_fd(name) cfg = ConfigDict({ "enabled": True, "libs": { "names": [name], "calls": True }, "output": { "file": None, "append": False, "dump": True } }) mp = MainProfiler() prof = LibProfiler() assert mp.parse_config(cfg) assert mp.add_profiler(prof) mp.setup() assert prof.names == [name] assert prof.add_calls p = prof.create_profile(name, fd) assert p mp.shutdown()
def libcore_profile_profiler_test(): name = 'vamostest.library' fd = read_lib_fd(name) c = LibProfilerConfig(profiling=True, libs=[name]) p = LibProfiler(c) assert not p.get_profile(name) prof = p.create_profile(name, fd) assert prof assert prof == p.get_profile(name) assert p.get_all_lib_names() == [name] assert p.get_num_libs() == 1
def libcore_profile_profiler_default_test(): name = 'dos.library' fd = read_lib_fd(name) prof = LibProfiler(names=[name]) prof.setup() p = prof.create_profile(name, fd) assert p assert prof.create_profile('bla', fd) is None assert prof.get_profile(name) == p assert prof.get_num_libs() == 1 assert prof.get_all_lib_names() == [name] prof.shutdown()
def __init__(self, machine, alloc, profiler_cfg=None): self.machine = machine self.mem = machine.get_mem() self.alloc = alloc self.lib_reg = LibRegistry() self.ctx_map = LibCtxMap(machine) self.profiler = LibProfiler(profiler_cfg) # tools self._setup_creator() # state self.exec_lib = None self.addr_vlib = {} self.name_vlib = {}
def _load_profile(self, args): # read file try: with open(args.input) as fh: data = json.load(fh) if "libs" in data: data = ConfigDict(data["libs"]) self.profiler = LibProfiler() self.profiler.set_data(data) return True else: print("no 'libs' found in '%s'" % args.input) return False except IOError as e: print("loading '%s' failed: %s" % (args.input, e)) return False
def libcore_create_lib_profile_test(): mem, traps, alloc, ctx = setup() impl = VamosTestLibrary() # create info for lib date = datetime.date(2012, 11, 12) info = LibInfo('vamostest.library', 42, 3, date) # create lib pc = LibProfilerConfig(profiling=True, all_libs=True) profiler = LibProfiler(pc) creator = LibCreator(alloc, traps, profiler=profiler) lib = creator.create_lib(info, ctx, impl) prof = profiler.get_profile('vamostest.library') assert prof # free lib lib.free() assert alloc.is_all_free()
def gen_prof(add_samples=False): name = 'vamostest.library' fd = read_lib_fd(name) cfg = LibProfilerConfig(profiling=True, all_libs=True, add_samples=add_samples) p = LibProfiler(cfg) lp = p.create_profile(name, fd) assert lp # get func func_name = "Add" func = fd.get_func_by_name(func_name) fp = lp.get_func_prof(func.get_index()) fp.count(1.0) fp.count(2.0) fp.count(3.0) return p, lp, fp
def libcore_create_lib_profile_test(): mem, traps, alloc, ctx = setup() impl = VamosTestLibrary() # create info for lib date = datetime.date(2012, 11, 12) info = LibInfo('vamostest.library', 42, 3, date) # create lib lib_profiler = LibProfiler(names=["all"]) creator = LibCreator(alloc, traps, lib_profiler=lib_profiler) lib_profiler.setup() lib = creator.create_lib(info, ctx, impl) profiler = creator.get_profiler() prof = profiler.get_profile('vamostest.library') assert prof assert lib.profile # free lib lib.free() assert alloc.is_all_free()
def __init__( self, machine, alloc, main_profiler=None, prof_names=None, prof_calls=False ): self.machine = machine self.mem = machine.get_mem() self.alloc = alloc self.lib_reg = LibRegistry() self.ctx_map = {} self.lib_profiler = LibProfiler(prof_names, prof_calls) if main_profiler: main_profiler.add_profiler(self.lib_profiler) # tools self._setup_creator() # state self.exec_lib = None self.addr_vlib = {} self.name_vlib = {} self.ctx_extra_attr = {}