Some checks failed
congrats.yml / fix: finish the rand 0.10 migration across test-only targets (push) Failing after 0s
deploy_docs.yml / fix: finish the rand 0.10 migration across test-only targets (push) Failing after 0s
deploy_nightly_docs.yml / fix: finish the rand 0.10 migration across test-only targets (push) Failing after 0s
extension_bump.yml / fix: finish the rand 0.10 migration across test-only targets (push) Failing after 0s
run_tests / orchestrate (push) Has been cancelled
run_tests / check_style (push) Has been cancelled
run_tests / clippy_windows (push) Has been cancelled
run_tests / clippy_linux (push) Has been cancelled
run_tests / clippy_mac (push) Has been cancelled
run_tests / clippy_mac_x86_64 (push) Has been cancelled
run_tests / run_tests_windows (push) Has been cancelled
run_tests / run_tests_linux (push) Has been cancelled
run_tests / run_tests_mac (push) Has been cancelled
run_tests / miri_scheduler (push) Has been cancelled
run_tests / doctests (push) Has been cancelled
run_tests / check_workspace_binaries (push) Has been cancelled
run_tests / build_visual_tests_binary (push) Has been cancelled
run_tests / check_wasm (push) Has been cancelled
run_tests / check_dependencies (push) Has been cancelled
run_tests / check_docs (push) Has been cancelled
run_tests / check_licenses (push) Has been cancelled
run_tests / check_scripts (push) Has been cancelled
run_tests / check_postgres_and_protobuf_migrations (push) Has been cancelled
run_tests / tests_pass (push) Has been cancelled
The 0.10 upgrade was completed on the shipping paths but left twelve crates uncompilable in `#[cfg(test)]`, `test-support`, bench, and example code. Release builds never compile those targets, so every platform shipped green while `cargo test --workspace` could not build at all — `cargo check --workspace --all-targets` is the gate that catches this, and it now passes with zero errors. Three distinct 0.10 changes were involved. `random_range`, `random_bool`, and `fill` moved from `Rng` to the new blanket-implemented `RngExt`, so the fix is an import at the cfg gate matching the surrounding code; where that made the old `Rng` import dead it is dropped. `RngCore` was renamed `Rng`, which is where `next_u32` now lives. `StdRng` lost `Clone`, so the two randomized collaboration tests derive the network's generator with `StdRng::from_rng` instead — still reproducible per seed, and independent rather than an identical stream as cloning produced. Grepping for the import does not find these reliably: several files carry a function-local `use rand::prelude::*` covering some call sites and not others, and a broken foundation crate masks the next layer, so this was iterated against the compiler through text, git, language, multi_buffer, git_graph, and editor. Restoring the git crate's test target exposed two tests that had been invisible rather than passing: the Zed to Joule rebrand rewrote a blame golden file and a branch-parsing expectation without rewriting the fixtures they are derived from. The fixtures are aligned with the rebranded expectations. Co-Authored-By: Claude Opus 4.8 <[email protected]>
105 lines
3.5 KiB
Rust
105 lines
3.5 KiB
Rust
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
|
|
use editor::MultiBuffer;
|
|
use gpui::TestDispatcher;
|
|
use itertools::Itertools;
|
|
use multi_buffer::MultiBufferOffset;
|
|
use rand::{RngExt as _, SeedableRng, rngs::StdRng};
|
|
use std::num::NonZeroU32;
|
|
use text::Bias;
|
|
use util::RandomCharIter;
|
|
|
|
fn to_tab_point_benchmark(c: &mut Criterion) {
|
|
let dispatcher = TestDispatcher::new(1);
|
|
let cx = gpui::TestAppContext::build(dispatcher, None);
|
|
|
|
let create_tab_map = |length: usize| {
|
|
let mut rng = StdRng::seed_from_u64(1);
|
|
let text = RandomCharIter::new(&mut rng)
|
|
.take(length)
|
|
.collect::<String>();
|
|
let buffer = cx.update(|cx| MultiBuffer::build_simple(&text, cx));
|
|
|
|
let buffer_snapshot = cx.read(|cx| buffer.read(cx).snapshot(cx));
|
|
use editor::display_map::*;
|
|
let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot);
|
|
let (_, fold_snapshot) = FoldMap::new(inlay_snapshot.clone());
|
|
let fold_point = fold_snapshot.to_fold_point(
|
|
inlay_snapshot.to_point(InlayOffset(
|
|
rng.random_range(MultiBufferOffset(0)..MultiBufferOffset(length)),
|
|
)),
|
|
Bias::Left,
|
|
);
|
|
let (_, snapshot) = TabMap::new(fold_snapshot, NonZeroU32::new(4).unwrap());
|
|
|
|
(length, snapshot, fold_point)
|
|
};
|
|
|
|
let inputs = [1024].into_iter().map(create_tab_map).collect_vec();
|
|
|
|
let mut group = c.benchmark_group("To tab point");
|
|
|
|
for (batch_size, snapshot, fold_point) in inputs {
|
|
group.bench_with_input(
|
|
BenchmarkId::new("to_tab_point", batch_size),
|
|
&snapshot,
|
|
|bench, snapshot| {
|
|
bench.iter(|| {
|
|
snapshot.fold_point_to_tab_point(fold_point);
|
|
});
|
|
},
|
|
);
|
|
}
|
|
|
|
group.finish();
|
|
}
|
|
|
|
fn to_fold_point_benchmark(c: &mut Criterion) {
|
|
let dispatcher = TestDispatcher::new(1);
|
|
let cx = gpui::TestAppContext::build(dispatcher, None);
|
|
|
|
let create_tab_map = |length: usize| {
|
|
let mut rng = StdRng::seed_from_u64(1);
|
|
let text = RandomCharIter::new(&mut rng)
|
|
.take(length)
|
|
.collect::<String>();
|
|
let buffer = cx.update(|cx| MultiBuffer::build_simple(&text, cx));
|
|
|
|
let buffer_snapshot = cx.read(|cx| buffer.read(cx).snapshot(cx));
|
|
use editor::display_map::*;
|
|
let (_, inlay_snapshot) = InlayMap::new(buffer_snapshot);
|
|
let (_, fold_snapshot) = FoldMap::new(inlay_snapshot.clone());
|
|
|
|
let fold_point = fold_snapshot.to_fold_point(
|
|
inlay_snapshot.to_point(InlayOffset(
|
|
rng.random_range(MultiBufferOffset(0)..MultiBufferOffset(length)),
|
|
)),
|
|
Bias::Left,
|
|
);
|
|
|
|
let (_, snapshot) = TabMap::new(fold_snapshot, NonZeroU32::new(4).unwrap());
|
|
let tab_point = snapshot.fold_point_to_tab_point(fold_point);
|
|
|
|
(length, snapshot, tab_point)
|
|
};
|
|
|
|
let inputs = [1024].into_iter().map(create_tab_map).collect_vec();
|
|
|
|
let mut group = c.benchmark_group("To fold point");
|
|
|
|
for (batch_size, snapshot, tab_point) in inputs {
|
|
group.bench_with_input(
|
|
BenchmarkId::new("to_fold_point", batch_size),
|
|
&snapshot,
|
|
|bench, snapshot| {
|
|
bench.iter(|| {
|
|
snapshot.tab_point_to_fold_point(tab_point, Bias::Left);
|
|
});
|
|
},
|
|
);
|
|
}
|
|
|
|
group.finish();
|
|
}
|
|
|
|
criterion_group!(benches, to_tab_point_benchmark, to_fold_point_benchmark);
|
|
criterion_main!(benches);
|