From 37d722d71cc4b441d40d15f07156e1d897b1642e Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Tue, 10 Oct 2023 11:00:58 +0100 Subject: [PATCH] Add table traversal benchmark --- benches/benchmark.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/benches/benchmark.rs b/benches/benchmark.rs index 4e56a0f..aa1b45b 100644 --- a/benches/benchmark.rs +++ b/benches/benchmark.rs @@ -84,6 +84,22 @@ fn table_get_set(c: &mut Criterion) { }); } +fn table_traversal(c: &mut Criterion) { + let lua = Lua::new(); + + c.bench_function("table traversal", |b| { + b.iter_batched( + || lua.globals(), + |globals| { + for kv in globals.pairs::() { + let (_k, _v) = kv.unwrap(); + } + }, + BatchSize::SmallInput, + ); + }); +} + fn create_function(c: &mut Criterion) { let lua = Lua::new(); @@ -331,6 +347,7 @@ criterion_group! { create_array, create_string_table, table_get_set, + table_traversal, create_function, call_lua_function, call_sum_callback,