Skip to content

Commit

Permalink
chore(term): add benchmark for rendering (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
ymgyt committed Jul 11, 2024
1 parent f116286 commit 0a1d4d3
Show file tree
Hide file tree
Showing 10 changed files with 337 additions and 44 deletions.
186 changes: 186 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ axum-server = { version = "0.6.0", features = ["tls-rustls"] }
bitflags = { version = "2.6.0", default-features = false }
chrono = { version = "0.4.38", default-features = false }
clap = { version = "4.5", default-features = false }
criterion = { version = "0.5.1", features = ["async_tokio"] }
either = { version = "1.13.0" }
fake = { version = "2.9.2", features = ["derive", "chrono"] }
fdlimit = { version = "0.3.0", default-features = false }
Expand Down
27 changes: 16 additions & 11 deletions crates/synd_term/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ serde = { workspace = true, features = ["derive"] }
serde_json = "1.0.120"
thiserror = { workspace = true }
tokio = { workspace = true, features = ["macros", "rt-multi-thread", "sync", "time"] }
tokio-stream = { version = "0.1.15", optional = true }
toml = { version = "0.8.14", default-features = true }
tracing = { workspace = true }
tracing-appender = "0.2.3"
Expand All @@ -60,22 +61,26 @@ url = { workspace = true }

[features]
# Integration test
integration = []
integration = ["dep:tokio-stream"]

[dev-dependencies]
synd-api = { path = "../synd_api" }
synd-test = { path = "../synd_test" }

assert_cmd = { workspace = true }
axum-server = { workspace = true }
fake = { workspace = true }
insta = { workspace = true }
kvsd = { workspace = true }
proptest = { workspace = true }
serial_test = { version = "3.1.1", default-features = false, features = ["async", "file_locks"] }
tempfile = { workspace = true }
tokio-stream = "0.1.15"
tokio-util = { workspace = true }
assert_cmd = { workspace = true }
axum-server = { workspace = true }
criterion = { workspace = true }
fake = { workspace = true }
insta = { workspace = true }
kvsd = { workspace = true }
proptest = { workspace = true }
serial_test = { version = "3.1.1", default-features = false, features = ["async", "file_locks"] }
tempfile = { workspace = true }
tokio-util = { workspace = true }

[[bench]]
harness = false
name = "render"

[lints]
workspace = true
Expand Down
40 changes: 40 additions & 0 deletions crates/synd_term/benches/bench/helper.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
use std::time::Duration;

use ratatui::backend::TestBackend;
use synd_term::{
application::{Application, Cache, Config},
client::Client,
config::Categories,
terminal::Terminal,
ui::theme::Theme,
};
use url::Url;

pub fn init_app() -> Application {
let terminal = {
let backend = TestBackend::new(120, 40);
let terminal = ratatui::Terminal::new(backend).unwrap();
Terminal::with(terminal)
};

let client = {
Client::new(
Url::parse("http://dummy.ymgyt.io").unwrap(),
Duration::from_secs(10),
)
.unwrap()
};

let config = { Config::default().with_idle_timer_interval(Duration::from_micros(1)) };

let cache = { Cache::new(tempfile::TempDir::new().unwrap().into_path()) };

Application::builder()
.terminal(terminal)
.client(client)
.categories(Categories::default_toml())
.config(config)
.cache(cache)
.theme(Theme::default())
.build()
}
Loading

0 comments on commit 0a1d4d3

Please sign in to comment.