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]>
167 lines
5.4 KiB
Rust
167 lines
5.4 KiB
Rust
use criterion::{Bencher, BenchmarkId};
|
|
use editor::{
|
|
Editor, EditorMode, MultiBuffer,
|
|
actions::{DeleteToPreviousWordStart, SelectAll, SplitSelectionIntoLines},
|
|
};
|
|
use gpui::{AppContext, Focusable as _, TestAppContext, TestDispatcher};
|
|
use rand::{RngExt as _, SeedableRng as _, rngs::StdRng};
|
|
use settings::SettingsStore;
|
|
use ui::IntoElement;
|
|
use util::RandomCharIter;
|
|
|
|
fn editor_input_with_1000_cursors(bencher: &mut Bencher<'_>, cx: &TestAppContext) {
|
|
let mut cx = cx.clone();
|
|
let text = String::from_iter(["line:\n"; 1000]);
|
|
let buffer = cx.update(|cx| MultiBuffer::build_simple(&text, cx));
|
|
|
|
let cx = cx.add_empty_window();
|
|
let editor = cx.update(|window, cx| {
|
|
let editor = cx.new(|cx| {
|
|
let mut editor = Editor::new(EditorMode::full(), buffer, None, window, cx);
|
|
editor.set_style(editor::EditorStyle::default(), window, cx);
|
|
editor.select_all(&SelectAll, window, cx);
|
|
editor.split_selection_into_lines(
|
|
&SplitSelectionIntoLines {
|
|
keep_selections: true,
|
|
},
|
|
window,
|
|
cx,
|
|
);
|
|
editor
|
|
});
|
|
window.focus(&editor.focus_handle(cx), cx);
|
|
editor
|
|
});
|
|
|
|
bencher.iter(|| {
|
|
cx.update(|window, cx| {
|
|
editor.update(cx, |editor, cx| {
|
|
editor.handle_input("hello world", window, cx);
|
|
editor.delete_to_previous_word_start(
|
|
&DeleteToPreviousWordStart {
|
|
ignore_newlines: false,
|
|
ignore_brackets: false,
|
|
},
|
|
window,
|
|
cx,
|
|
);
|
|
editor.delete_to_previous_word_start(
|
|
&DeleteToPreviousWordStart {
|
|
ignore_newlines: false,
|
|
ignore_brackets: false,
|
|
},
|
|
window,
|
|
cx,
|
|
);
|
|
});
|
|
})
|
|
});
|
|
}
|
|
|
|
fn open_editor_with_one_long_line(bencher: &mut Bencher<'_>, args: &(String, TestAppContext)) {
|
|
let (text, cx) = args;
|
|
let mut cx = cx.clone();
|
|
|
|
bencher.iter(|| {
|
|
let buffer = cx.update(|cx| MultiBuffer::build_simple(&text, cx));
|
|
|
|
let cx = cx.add_empty_window();
|
|
let _ = cx.update(|window, cx| {
|
|
let editor = cx.new(|cx| {
|
|
let mut editor = Editor::new(EditorMode::full(), buffer, None, window, cx);
|
|
editor.set_style(editor::EditorStyle::default(), window, cx);
|
|
editor
|
|
});
|
|
window.focus(&editor.focus_handle(cx), cx);
|
|
editor
|
|
});
|
|
});
|
|
}
|
|
|
|
fn editor_render(bencher: &mut Bencher<'_>, cx: &TestAppContext) {
|
|
let mut cx = cx.clone();
|
|
let buffer = cx.update(|cx| {
|
|
let mut rng = StdRng::seed_from_u64(1);
|
|
let text_len = rng.random_range(10000..90000);
|
|
if rng.random() {
|
|
let text = RandomCharIter::new(&mut rng)
|
|
.take(text_len)
|
|
.collect::<String>();
|
|
MultiBuffer::build_simple(&text, cx)
|
|
} else {
|
|
MultiBuffer::build_random(&mut rng, cx)
|
|
}
|
|
});
|
|
|
|
let cx = cx.add_empty_window();
|
|
let editor = cx.update(|window, cx| {
|
|
let editor = cx.new(|cx| {
|
|
let mut editor = Editor::new(EditorMode::full(), buffer, None, window, cx);
|
|
editor.set_style(editor::EditorStyle::default(), window, cx);
|
|
editor
|
|
});
|
|
window.focus(&editor.focus_handle(cx), cx);
|
|
editor
|
|
});
|
|
|
|
bencher.iter(|| {
|
|
cx.update(|window, cx| {
|
|
// editor.update(cx, |editor, cx| editor.move_down(&MoveDown, window, cx));
|
|
let mut view = editor.clone().into_any_element();
|
|
let _ = view.request_layout(window, cx);
|
|
let _ = view.prepaint(window, cx);
|
|
view.paint(window, cx);
|
|
});
|
|
})
|
|
}
|
|
|
|
pub fn benches() {
|
|
let dispatcher = TestDispatcher::new(1);
|
|
let cx = gpui::TestAppContext::build(dispatcher, None);
|
|
cx.update(|cx| {
|
|
let store = SettingsStore::test(cx);
|
|
cx.set_global(store);
|
|
assets::Assets.load_test_fonts(cx);
|
|
theme_settings::init(theme::LoadThemes::JustBase, cx);
|
|
// release_channel::init(semver::Version::new(0,0,0), cx);
|
|
editor::init(cx);
|
|
});
|
|
|
|
let mut criterion: criterion::Criterion<_> =
|
|
(criterion::Criterion::default()).configure_from_args();
|
|
|
|
// setup app context
|
|
let mut group = criterion.benchmark_group("Time to render");
|
|
group.bench_with_input(
|
|
BenchmarkId::new("editor_render", "TestAppContext"),
|
|
&cx,
|
|
editor_render,
|
|
);
|
|
|
|
group.finish();
|
|
|
|
let text = String::from_iter(["char"; 1000]);
|
|
let mut group = criterion.benchmark_group("Build buffer with one long line");
|
|
group.bench_with_input(
|
|
BenchmarkId::new("editor_with_one_long_line", "(String, TestAppContext )"),
|
|
&(text, cx.clone()),
|
|
open_editor_with_one_long_line,
|
|
);
|
|
|
|
group.finish();
|
|
|
|
let mut group = criterion.benchmark_group("multi cursor edits");
|
|
group.bench_with_input(
|
|
BenchmarkId::new("editor_input_with_1000_cursors", "TestAppContext"),
|
|
&cx,
|
|
editor_input_with_1000_cursors,
|
|
);
|
|
group.finish();
|
|
}
|
|
|
|
fn main() {
|
|
benches();
|
|
criterion::Criterion::default()
|
|
.configure_from_args()
|
|
.final_summary();
|
|
}
|