Skip to content

Commit ccca390

Browse files
shaobo-he-awscdisselkoen
authored andcommitted
Replace criterion::black_box with std::hint::black_box (#1630)
Signed-off-by: Shaobo He <[email protected]>
1 parent bc3561e commit ccca390

File tree

6 files changed

+13
-9
lines changed

6 files changed

+13
-9
lines changed

cedar-policy/benches/attr_errors.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
#![allow(clippy::unwrap_used)]
1818
use cedar_policy::EntityUid;
1919
use cedar_policy::{Authorizer, Context, Entities, PolicySet, Request, RestrictedExpression};
20-
use criterion::{black_box, criterion_group, criterion_main, Criterion};
20+
use criterion::{criterion_group, criterion_main, Criterion};
21+
use std::hint::black_box;
2122
use std::str::FromStr;
2223

2324
const LARGE_SIZE: usize = 100_000;

cedar-policy/benches/cedar_benchmarks.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
// PANIC SAFETY benchmarking
1919
#![allow(clippy::expect_used)]
2020

21-
use std::str::FromStr;
21+
use std::{hint::black_box, str::FromStr};
2222

2323
use cedar_policy::{
2424
Authorizer, Context, Entities, EntityId, EntityTypeName, EntityUid, Policy, PolicySet, Request,
2525
RestrictedExpression,
2626
};
2727

28-
use criterion::{black_box, criterion_group, criterion_main, Criterion};
28+
use criterion::{criterion_group, criterion_main, Criterion};
2929

3030
pub fn criterion_benchmark(c: &mut Criterion) {
3131
let auth = Authorizer::new();

cedar-policy/benches/deeply_nested_est.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17+
use std::hint::black_box;
18+
1719
use cedar_policy::Policy;
1820

19-
use criterion::{black_box, criterion_group, criterion_main, Criterion};
21+
use criterion::{criterion_group, criterion_main, Criterion};
2022

2123
// PANIC SAFETY: benchmarking
2224
#[allow(clippy::unwrap_used)]

cedar-policy/benches/entity_attr_errors.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121
use cedar_policy::{
2222
Authorizer, Context, Entities, Entity, EntityUid, PolicySet, Request, RestrictedExpression,
2323
};
24-
use criterion::{black_box, criterion_group, criterion_main, Criterion};
24+
use criterion::{criterion_group, criterion_main, Criterion};
2525
use std::{
2626
collections::{HashMap, HashSet},
27+
hint::black_box,
2728
str::FromStr,
2829
};
2930

cedar-policy/benches/entity_parsing.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// PANIC SAFETY: it's ok for benchmarking code to panic
22
#![allow(clippy::unwrap_used)]
33

4-
use std::str::FromStr;
4+
use std::{hint::black_box, str::FromStr};
55

66
use cedar_policy::EntityTypeName;
77

8-
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
8+
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
99

1010
fn entity_type_name_parsing(c: &mut Criterion) {
1111
let mut group = c.benchmark_group("EntityTypeName parsing");

cedar-policy/benches/extension_fn_validation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17-
use std::str::FromStr;
17+
use std::{hint::black_box, str::FromStr};
1818

1919
use cedar_policy::{Policy, PolicySet, Schema, Validator};
2020

21-
use criterion::{black_box, criterion_group, criterion_main, Criterion};
21+
use criterion::{criterion_group, criterion_main, Criterion};
2222

2323
// PANIC SAFETY: benchmarking
2424
#[allow(clippy::unwrap_used)]

0 commit comments

Comments
 (0)