Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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()
Ejemplo n.º 4
0
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()
Ejemplo n.º 5
0
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()
Ejemplo n.º 6
0
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()
Ejemplo n.º 7
0
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
Ejemplo n.º 8
0
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
Ejemplo n.º 9
0
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
Ejemplo n.º 10
0
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
Ejemplo n.º 11
0
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
Ejemplo n.º 12
0
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