phys-collision 2.0.1-beta.0

Provides collision detection ability
// Copyright (C) 2020-2025 phys-collision authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use criterion::{black_box, criterion_group, criterion_main, Criterion};

#[inline]
fn mod3_const_array(index: usize) -> usize {
    const MOD3: [usize; 3] = [1, 2, 0];
    MOD3[index]
}

fn mod3_bench(c: &mut Criterion) {
    let mut index = 0;
    c.bench_function("mod3_const_array", |iter| {
        iter.iter(|| index = black_box(mod3_const_array(black_box(index))))
    });
    black_box(index);
    c.bench_function("mod3", |iter| {
        iter.iter(|| {
            index = black_box((index + 1) % 3);
        })
    });
    black_box(index);
}

criterion_group!(benches_mod3, mod3_bench);

criterion_main!(benches_mod3);