Ejemplo n.º 1
0
def libcore_profile_data_samples_test():
  # from fd
  name = 'dos.library'
  fd = read_lib_fd(name)
  prof = LibProfileData(fd, True)
  # get func
  func_name = "Input"
  func = fd.get_func_by_name(func_name)
  idx = func.get_index()
  func_prof = prof.get_func_by_index(idx)
  assert func_prof
  assert func_prof.get_func_id() == idx
  # count
  func_prof.count(1.0)
  func_prof.count(2.0)
  func_prof.count(3.0)
  assert prof.get_total() == (3, 6.0, 2.0)
  assert prof.get_total_str() == \
      "LIB TOTAL                  3 calls    6000.000 ms" \
      "  avg    2000.000 ms"
  prof.remove_empty()
  # to/from dict
  data_dict = prof.get_data()
  prof2 = LibProfileData.from_dict(data_dict)
  assert prof == prof2
  # get func
  prof2.setup_func_table(fd)
  func_prof2 = prof2.get_func_by_index(func.get_index())
  assert func_prof == func_prof2
Ejemplo n.º 2
0
def libcore_profile_data_samples_test():
  # from fd
  name = 'dos.library'
  fd = read_lib_fd(name)
  prof = LibProfileData(fd, True)
  # get func
  func_name = "Input"
  func = fd.get_func_by_name(func_name)
  idx = func.get_index()
  func_prof = prof.get_func_by_index(idx)
  assert func_prof
  assert func_prof.get_func_id() == idx
  # count
  func_prof.count(1.0)
  func_prof.count(2.0)
  func_prof.count(3.0)
  assert prof.get_total() == (3, 6.0, 2.0)
  assert prof.get_total_str() == \
      "LIB TOTAL                  3 calls    6000.000 ms" \
      "  avg    2000.000 ms"
  prof.remove_empty()
  # to/from dict
  data_dict = prof.get_data()
  prof2 = LibProfileData.from_dict(data_dict)
  assert prof == prof2
  # get func
  prof2.setup_func_table(fd)
  func_prof2 = prof2.get_func_by_index(func.get_index())
  assert func_prof == func_prof2
Ejemplo n.º 3
0
def libcore_profile_data_test():
    # from fd
    name = "dos.library"
    fd = read_lib_fd(name)
    prof = LibProfileData(fd)
    # get func
    func_name = "Input"
    func = fd.get_func_by_name(func_name)
    idx = func.get_index()
    func_prof = prof.get_func_by_index(idx)
    assert func_prof
    assert func_prof.get_func_id() == idx
    assert prof.get_func_by_name(func_name) == func_prof
    # count
    func_prof.count(1.0)
    func_prof.count(2.0)
    func_prof.count(3.0)
    assert prof.get_total() == (3, 6.0, 2.0)
    assert (
        prof.get_total_str() == "LIB TOTAL                  3 calls    6000.000 ms"
        "  avg    2000.000 ms"
    )
    prof.remove_empty()
    assert [x for x in prof.get_all_funcs()] == [(func_name, func_prof)]
    # to/from dict
    data_dict = prof.get_data()
    prof2 = LibProfileData.from_dict(data_dict)
    assert prof == prof2
    # get func
    prof2.setup_func_table(fd)
    func_prof2 = prof2.get_func_by_index(idx)
    assert func_prof == func_prof2