Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sklbench/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def read_output_from_command(command: str) -> Tuple[int, str, str]:
)


def hash_from_json_repr(x: JsonTypesUnion, hash_limit: int = 5) -> str:
def hash_from_json_repr(x: JsonTypesUnion, hash_limit: Union[int, None] = 5) -> str:
h = hashlib.sha256()
h.update(bytes(json.dumps(x), encoding="utf-8"))
return h.hexdigest()[:hash_limit]
Expand Down
8 changes: 5 additions & 3 deletions sklbench/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,19 +206,21 @@ def expand_template(


def remove_duplicated_bench_cases(bench_cases: List[BenchCase]) -> List[BenchCase]:
# full hash: the default 5 hex digits collide for different cases
# in runs with ~1000+ cases, which silently dropped one of them
hash_map = dict()
for bench_case in bench_cases:
hash_map[hash_from_json_repr(bench_case)] = bench_case
hash_map[hash_from_json_repr(bench_case, hash_limit=None)] = bench_case
return list(hash_map.values())


def bench_case_filter(bench_case: BenchCase, filters: List[BenchCase]):
# filtering is implemented by comparison of
# benchmark case and case merged with filters:
# filtering is passed if one of merged cases has same hash as original
original_hash = hash_from_json_repr(bench_case)
original_hash = hash_from_json_repr(bench_case, hash_limit=None)
filtered_hashes = [
hash_from_json_repr(merge_dicts(bench_case, bench_filter))
hash_from_json_repr(merge_dicts(bench_case, bench_filter), hash_limit=None)
for bench_filter in filters
]
return original_hash in filtered_hashes or len(filtered_hashes) == 0
Expand Down
Loading