codephage2020 commented on PR #7908: URL: https://github.com/apache/arrow-rs/pull/7908#issuecomment-3067028130
CC @alamb @scovich . I conducted a simple benchmark test locally. result: ``` direct_slice_at_offset_zero time: [1.0067 ns 1.0092 ns 1.0122 ns] change: [−0.9043% −0.2643% +0.3090%] (p = 0.42 > 0.05) No change in performance detected. Found 6 outliers among 100 measurements (6.00%) 4 (4.00%) high mild 2 (2.00%) high severe branched_slice_at_offset_zero time: [1.4050 ns 1.4100 ns 1.4157 ns] change: [−0.3173% +0.0921% +0.4766%] (p = 0.65 > 0.05) No change in performance detected. Found 2 outliers among 100 measurements (2.00%) 1 (1.00%) high mild 1 (1.00%) high severe ``` @scovich The results show that you are right. And I will delete the branch for testing zero. Below is the code for the benchmark test. Please let me know if there are any issues. This is a temporary test and I won't submit it. ```rust const LARGE_DATA_SIZE: usize = 1 << 20; fn setup_data() -> Vec<u8> { let mut rng = StdRng::seed_from_u64(42); (0..LARGE_DATA_SIZE).map(|_| rng.random()).collect() } fn bench_simple_direct(c: &mut Criterion) { let data = setup_data(); let range = 0..1000; c.bench_function("direct_slice_at_offset_zero", |b| { b.iter(|| { let _ = black_box(slice_from_slice_at_offset(&data, 0, range.clone())); }) }); } fn bench_with_branch_zero_offset(c: &mut Criterion) { let data = setup_data(); let range = 0..1000; let offset = 0; c.bench_function("branched_slice_at_offset_zero", |b| { b.iter(|| { let _ = black_box(match offset { 0 => slice_from_slice(&data, range.clone()), _ => slice_from_slice_at_offset(&data, offset, range.clone()), }); }) }); } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org