mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
added insert_char benchmark
This commit is contained in:
parent
59509748b5
commit
55cd6a4976
5 changed files with 65 additions and 2 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -2659,6 +2659,7 @@ dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"cgmath",
|
"cgmath",
|
||||||
"colored",
|
"colored",
|
||||||
|
"criterion",
|
||||||
"env_logger 0.7.1",
|
"env_logger 0.7.1",
|
||||||
"futures",
|
"futures",
|
||||||
"glyph_brush",
|
"glyph_brush",
|
||||||
|
|
|
@ -34,3 +34,6 @@ members = [
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = "fat"
|
lto = "fat"
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
|
debug = true # enable when profiling
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,11 @@ maplit = "1.0.1"
|
||||||
indoc = "0.3.3"
|
indoc = "0.3.3"
|
||||||
quickcheck = "0.8"
|
quickcheck = "0.8"
|
||||||
quickcheck_macros = "0.8"
|
quickcheck_macros = "0.8"
|
||||||
|
criterion = "0.3"
|
||||||
|
|
||||||
|
[[bench]]
|
||||||
|
name = "my_benchmark"
|
||||||
|
harness = false
|
||||||
|
|
||||||
# uncomment everything below if you have made changes to any shaders and
|
# uncomment everything below if you have made changes to any shaders and
|
||||||
# want to compile them to .spv
|
# want to compile them to .spv
|
||||||
|
|
52
editor/benches/my_benchmark.rs
Normal file
52
editor/benches/my_benchmark.rs
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
|
||||||
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
|
use roc_editor::mvc::update::handle_new_char;
|
||||||
|
use roc_editor::mvc::ed_model::{EdModel, Position, RawSelection};
|
||||||
|
use roc_editor::mvc::app_model::AppModel;
|
||||||
|
use roc_editor::text_buffer::TextBuffer;
|
||||||
|
use ropey::Rope;
|
||||||
|
|
||||||
|
// duplicate inside mvc::update
|
||||||
|
fn mock_app_model(
|
||||||
|
text_buf: TextBuffer,
|
||||||
|
caret_pos: Position,
|
||||||
|
selection_opt: Option<RawSelection>,
|
||||||
|
) -> AppModel {
|
||||||
|
AppModel {
|
||||||
|
ed_model_opt: Some(EdModel {
|
||||||
|
text_buf,
|
||||||
|
caret_pos,
|
||||||
|
selection_opt,
|
||||||
|
glyph_dim_rect_opt: None,
|
||||||
|
has_focus: true,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn text_buffer_from_str(lines_str: &str) -> TextBuffer {
|
||||||
|
TextBuffer {
|
||||||
|
text_rope: Rope::from_str(lines_str),
|
||||||
|
path_str: "".to_owned(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn char_insert_benchmark(c: &mut Criterion) {
|
||||||
|
let text_buf = text_buffer_from_str("");
|
||||||
|
|
||||||
|
let caret_pos = Position {
|
||||||
|
line: 0,
|
||||||
|
column: 0
|
||||||
|
};
|
||||||
|
|
||||||
|
let selection_opt: Option<RawSelection> = None;
|
||||||
|
let mut app_model = mock_app_model(text_buf, caret_pos, selection_opt);
|
||||||
|
c.bench_function("single char insert, small buffer", |b| b.iter(|| handle_new_char(&mut app_model, &'a')));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn file_open_benchmark(c: &mut Criterion) {
|
||||||
|
ed_model::init_model(path)
|
||||||
|
//TODO continue here
|
||||||
|
}
|
||||||
|
|
||||||
|
criterion_group!(benches, char_insert_benchmark);
|
||||||
|
criterion_main!(benches);
|
|
@ -46,10 +46,12 @@ pub mod error;
|
||||||
pub mod graphics;
|
pub mod graphics;
|
||||||
mod keyboard_input;
|
mod keyboard_input;
|
||||||
pub mod lang;
|
pub mod lang;
|
||||||
mod mvc;
|
//mod mvc;
|
||||||
|
pub mod mvc; // for benchmarking
|
||||||
mod resources;
|
mod resources;
|
||||||
mod selection;
|
mod selection;
|
||||||
mod text_buffer;
|
//mod text_buffer;
|
||||||
|
pub mod text_buffer; // for benchmarking
|
||||||
mod util;
|
mod util;
|
||||||
mod vec_result;
|
mod vec_result;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue