Skip to content

Commit b480a8f

Browse files
Add egraph.run_report() method to print overall stats
1 parent 1a2ee10 commit b480a8f

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

docs/reference/egglog-translation.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,15 @@ egraph.function_size(Math)
522522
egraph.all_function_sizes()
523523
```
524524

525+
## Overall Statistics
526+
527+
The `(print-stats)` command is translated into `egraph.run_report()` to get overall statistics about the EGraph.
528+
529+
```{code-cell} python
530+
# (print-stats)
531+
egraph.run_report()
532+
```
533+
525534
## Include
526535

527536
The `(include <path>)` command is used to add modularity, by allowing you to pull in the source from another egglog file into the current file.

python/egglog/egraph.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,14 @@ def _run_schedule(self, schedule: Schedule) -> bindings.RunReport:
909909
assert isinstance(command_output, bindings.RunScheduleOutput)
910910
return command_output.report
911911

912+
def run_report(self) -> RunReport:
913+
"""
914+
Returns the overall run report for the egraph.
915+
"""
916+
(output,) = self._egraph.run_program(bindings.PrintOverallStatistics())
917+
assert isinstance(output, bindings.OverallStatistics)
918+
return output.report
919+
912920
def check_bool(self, *facts: FactLike) -> bool:
913921
"""
914922
Returns true if the facts are true in the egraph.

python/tests/test_high_level.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,3 +1048,7 @@ def test_all_function_size():
10481048
(C, 1),
10491049
(E.cm, 1),
10501050
}
1051+
1052+
1053+
def test_overall_run_report():
1054+
assert EGraph().run_report()

0 commit comments

Comments
 (0)