Skip to content

Commit 7d0aa7c

Browse files
committed
Add "table traversal sequence" benchmark
1 parent 2a3980e commit 7d0aa7c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

benches/benchmark.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,24 @@ fn table_traversal_for_each(c: &mut Criterion) {
112112
});
113113
}
114114

115+
fn table_traversal_sequence(c: &mut Criterion) {
116+
let lua = Lua::new();
117+
118+
let table = lua.create_sequence_from(1..1000).unwrap();
119+
120+
c.bench_function("table traversal [sequence]", |b| {
121+
b.iter_batched(
122+
|| table.clone(),
123+
|table| {
124+
for v in table.sequence_values::<i32>() {
125+
let _i = v.unwrap();
126+
}
127+
table_traversal_sequence},
128+
BatchSize::SmallInput,
129+
);
130+
});
131+
}
132+
115133
fn create_function(c: &mut Criterion) {
116134
let lua = Lua::new();
117135

@@ -361,6 +379,7 @@ criterion_group! {
361379
table_get_set,
362380
table_traversal_pairs,
363381
table_traversal_for_each,
382+
table_traversal_sequence,
364383
create_function,
365384
call_lua_function,
366385
call_sum_callback,

0 commit comments

Comments
 (0)