Skip to content

Commit

Permalink
sort by location then count
Browse files Browse the repository at this point in the history
-  update point counts to sorted df
-  remove unsorted expected locations
  • Loading branch information
JoseSantosAMD committed Jul 14, 2023
1 parent 8b175e5 commit d75a29e
Showing 1 changed file with 22 additions and 33 deletions.
55 changes: 22 additions & 33 deletions source/python/gui/source/tests/test_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ def test_parse_files_valid_directory():
[samples_df[0:3], samples_df[100:103], samples_df[150:153]]
)["count"].to_numpy()

# only one file given, so expected values change
_samples_df_expected_locations = [
"/home/jose/omnitrace/examples/causal/causal.cpp:103",
"/home/jose/omnitrace/examples/causal/causal.cpp:110",
Expand Down Expand Up @@ -385,8 +386,6 @@ def test_parse_files_valid_directory():


def test_parse_files_invalid_experiment():
############################################################

# test given invalid experiment
results_df, samples_df, file_names_run = parse_files(
input_files,
Expand Down Expand Up @@ -610,19 +609,6 @@ def test_parse_files_valid_speedup():
os.path.join(workload_dir, "experiments4.json"),
]

_samples_df_expected_locations = [
"main",
"/home/jose/omnitrace/examples/causal/causal.cpp:103",
"/home/jose/omnitrace/examples/causal/causal.cpp:110",
"/usr/include/c++/9/bits/stl_vector.h:1140",
"/usr/include/c++/9/bits/stl_vector.h:125",
"/usr/include/c++/9/bits/stl_vector.h:128",
"/usr/include/c++/9/ext/string_conversions.h:82",
"/usr/include/c++/9/ext/string_conversions.h:83",
"/usr/include/c++/9/ext/string_conversions.h:84",
]
_samples_df_expected_counts = [169, 152, 304, 304, 152, 152, 760, 3648, 456]

# test given valid speedup
results_df, samples_df, file_names_run = parse_files(
input_files,
Expand All @@ -645,6 +631,8 @@ def test_parse_files_valid_speedup():
results_df_expected_impact_err = np.full(2, 0)
results_df_expected_point_count = np.full(2, 2.0)

samples_df = samples_df.sort_values(by=["location", "count"])

assert sorted(file_names_run) == sorted(file_names)

samples_df_locations = pd.concat(
Expand All @@ -654,8 +642,8 @@ def test_parse_files_valid_speedup():
[samples_df[0:3], samples_df[100:103], samples_df[150:153]]
)["count"].to_list()

assert samples_df_locations == _samples_df_expected_locations
assert samples_df_counts == _samples_df_expected_counts
assert samples_df_locations == samples_df_expected_locations
assert samples_df_counts == samples_df_expected_counts

# assert expected speedup err
assert (top_df["program speedup"].to_numpy() == top_df_expected_program_speedup).all()
Expand Down Expand Up @@ -1404,7 +1392,7 @@ def test_compute_sorts():
results_df = pd.concat(
[results_df, compute_sorts(compute_speedups(dict_data, [], 0, [], False))]
)

results_df = results_df.sort_values(by=["idx", "line speedup"])
expected_speedup = [
0.0,
0.0,
Expand All @@ -1414,11 +1402,6 @@ def test_compute_sorts():
0.0,
0.0,
0.0,
1.0,
1.0,
1.0,
1.0,
1.0,
0.0,
0.0,
0.0,
Expand All @@ -1429,6 +1412,11 @@ def test_compute_sorts():
0.0,
0.0,
0.0,
1.0,
1.0,
1.0,
1.0,
1.0,
0.0,
0.0,
0.0,
Expand All @@ -1440,6 +1428,16 @@ def test_compute_sorts():
]

expected_point_count = [
2.0,
2.0,
4.0,
4.0,
4.0,
4.0,
4.0,
4.0,
4.0,
4.0,
4.0,
4.0,
4.0,
Expand All @@ -1453,8 +1451,6 @@ def test_compute_sorts():
5.0,
5.0,
5.0,
2.0,
2.0,
6.0,
6.0,
6.0,
Expand All @@ -1463,14 +1459,6 @@ def test_compute_sorts():
6.0,
2.0,
2.0,
4.0,
4.0,
4.0,
4.0,
4.0,
4.0,
4.0,
4.0,
]

assert results_df["max speedup"].to_list() == expected_speedup
Expand All @@ -1480,6 +1468,7 @@ def test_compute_sorts():

def test_parse_uploaded_file():
file_name = os.path.join(workload_dir, "experiments.json")
# expected locations changes because only one file is given
_samples_df_expected_locations = [
"/home/jose/omnitrace/examples/causal/causal.cpp:103",
"/home/jose/omnitrace/examples/causal/causal.cpp:110",
Expand Down

0 comments on commit d75a29e

Please sign in to comment.