|
1 |
| -use std::sync::Arc; |
2 |
| - |
3 | 1 | use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
|
4 | 2 | use yang3::context::{Context, ContextFlags};
|
5 | 3 | use yang3::data::{Data, DataDiffFlags, DataTree, DataValidationFlags};
|
6 | 4 |
|
7 | 5 | static SEARCH_DIR: &str = "./assets/yang/";
|
8 | 6 |
|
9 |
| -fn data_generate(ctx: &Arc<Context>, interfaces: u32) -> DataTree { |
| 7 | +fn data_generate(ctx: &Context, interfaces: u32) -> DataTree { |
10 | 8 | let mut dtree = DataTree::new(ctx);
|
11 | 9 |
|
12 | 10 | for i in 1..=interfaces {
|
@@ -38,18 +36,14 @@ fn criterion_benchmark(c: &mut Criterion) {
|
38 | 36 | ];
|
39 | 37 |
|
40 | 38 | // Initialize context.
|
41 |
| - let mut ctx = Arc::new( |
42 |
| - Context::new(ContextFlags::NO_YANGLIBRARY) |
43 |
| - .expect("Failed to create context"), |
44 |
| - ); |
45 |
| - (*Arc::get_mut(&mut ctx).unwrap()) |
46 |
| - .set_searchdir(SEARCH_DIR) |
| 39 | + let mut ctx = Context::new(ContextFlags::NO_YANGLIBRARY) |
| 40 | + .expect("Failed to create context"); |
| 41 | + ctx.set_searchdir(SEARCH_DIR) |
47 | 42 | .expect("Failed to set YANG search directory");
|
48 | 43 |
|
49 | 44 | // Load YANG modules.
|
50 | 45 | for module_name in &["ietf-interfaces", "iana-if-type"] {
|
51 |
| - (*Arc::get_mut(&mut ctx).unwrap()) |
52 |
| - .load_module(module_name, None, &[]) |
| 46 | + ctx.load_module(module_name, None, &[]) |
53 | 47 | .expect("Failed to load module");
|
54 | 48 | }
|
55 | 49 |
|
|
0 commit comments