Skip to content

Commit

Permalink
Optimize set operations in ExplorationReport (#262)
Browse files Browse the repository at this point in the history
`set.union` becomes slow significantly when set size large than 100k.
Test with
```python
from tqdm import tqdm
s = set()
for i in tqdm(range(200000)):
    s = s.union([i])
```
in comparison to
```python
from tqdm import tqdm
s = set()
for i in tqdm(range(200000)):
    s.update([i])
```

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Performance Improvements**
- Enhanced the efficiency of accuracy value aggregation by modifying how
accuracy values are updated, potentially improving performance in
scenarios with large or frequently updated data.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: zjgemi <[email protected]>
  • Loading branch information
zjgemi authored Sep 12, 2024
1 parent a8ca7f0 commit 7b8e942
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dpgen2/exploration/report/report_adaptive_lower.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def record(
ii, md_f[ii], md_v[ii]
)
self.nframes += add_nframes
self.accur = self.accur.union(add_accur)
self.accur.update(add_accur)
self.failed += add_failed
coll_f += add_f
coll_v += add_v
Expand Down

0 comments on commit 7b8e942

Please sign in to comment.