|
| 1 | +import pandas as pd |
| 2 | + |
| 3 | +from xorq.common.utils.import_utils import ( |
| 4 | + import_from_github, |
| 5 | +) |
| 6 | +from xorq.common.utils.perf_utils import ( |
| 7 | + compare_runs, |
| 8 | +) |
| 9 | + |
| 10 | + |
| 11 | +tag = "v0.2.2" |
| 12 | +lib = import_from_github( |
| 13 | + "xorq-labs", "xorq", "examples/complex_cached_expr.py", tag=tag |
| 14 | +) |
| 15 | +(train_predicted, *_) = lib.make_exprs() |
| 16 | + |
| 17 | + |
| 18 | +if __name__ == "__main__": |
| 19 | + (cleared, uncached_df, cached_df) = compare_runs(train_predicted) |
| 20 | + uncached_duration, cached_duration = ( |
| 21 | + (df.end_datetime.max() - df.start_datetime.min()).total_seconds() |
| 22 | + for df in (uncached_df, cached_df) |
| 23 | + ) |
| 24 | + delta_series = pd.Series( |
| 25 | + { |
| 26 | + "uncached_duration": uncached_duration, |
| 27 | + "cached_duration": cached_duration, |
| 28 | + "delta_duration": cached_duration - uncached_duration, |
| 29 | + } |
| 30 | + ) |
| 31 | + (cache_miss_events, cache_hit_events) = ( |
| 32 | + pd.concat( |
| 33 | + ( |
| 34 | + pd.DataFrame( |
| 35 | + dct for dct in trace.cache_event_dcts if dct["name"] == name |
| 36 | + ) |
| 37 | + for trace in df.trace |
| 38 | + ), |
| 39 | + ignore_index=True, |
| 40 | + ) |
| 41 | + for (df, name) in ( |
| 42 | + (uncached_df, "cache.miss"), |
| 43 | + (cached_df, "cache.hit"), |
| 44 | + ) |
| 45 | + ) |
| 46 | + print(delta_series.round(2)) |
0 commit comments