Skip to content

Commit 5b3f421

Browse files
petrmitrichevcopybara-github
authored andcommitted
Add benchmarks for kd.map_py and kd.map.
PiperOrigin-RevId: 720551250 Change-Id: I48709217bf4dfbeda2ab1387468438c87909a929
1 parent deff2c9 commit 5b3f421

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

py/koladata/benchmarks.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,5 +1467,32 @@ def expand_to(state):
14671467
_ = ds.expand_to(child_ds, ndim=ndim)
14681468

14691469

1470+
@google_benchmark.register
1471+
def map_py(state):
1472+
"""Benchmark for kd.map_py."""
1473+
x = kd.range(int(1e3))
1474+
fn = lambda x: x + 1
1475+
while state:
1476+
_ = kd.map_py(fn, x)
1477+
1478+
1479+
@google_benchmark.register
1480+
def map_with_traced_fn(state):
1481+
"""Benchmark for kd.map with a traced fn inside."""
1482+
x = kd.range(int(1e3))
1483+
fn = kd.fn(lambda x: x + 1)
1484+
while state:
1485+
_ = kd.map(fn, x)
1486+
1487+
1488+
@google_benchmark.register
1489+
def map_with_py_fn(state):
1490+
"""Benchmark for kd.map with a py_fn inside."""
1491+
x = kd.range(int(1e3))
1492+
fn = kd.py_fn(lambda x: x + 1)
1493+
while state:
1494+
_ = kd.map(fn, x)
1495+
1496+
14701497
if __name__ == '__main__':
14711498
google_benchmark.main()

0 commit comments

Comments
 (0)