Add advanced shaping benchmark to benches::wgpu
This commit is contained in:
parent
17281dd09b
commit
7b21a4d702
1 changed files with 32 additions and 3 deletions
|
|
@ -63,6 +63,15 @@ pub fn wgpu_benchmark(c: &mut Criterion) {
|
||||||
c.bench_function("wgpu - dynamic text (heavy)", |b| {
|
c.bench_function("wgpu - dynamic text (heavy)", |b| {
|
||||||
benchmark(b, &adapter, &device, &queue, |i| dynamic_text(100_000, i));
|
benchmark(b, &adapter, &device, &queue, |i| dynamic_text(100_000, i));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
c.bench_function("wgpu - advanced shaping (light)", |b| {
|
||||||
|
benchmark(b, &adapter, &device, &queue, |i| advanced_shaping(1_000, i));
|
||||||
|
});
|
||||||
|
c.bench_function("wgpu - advanced shaping (heavy)", |b| {
|
||||||
|
benchmark(b, &adapter, &device, &queue, |i| {
|
||||||
|
advanced_shaping(100_000, i)
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn benchmark<'a>(
|
fn benchmark<'a>(
|
||||||
|
|
@ -202,7 +211,7 @@ fn scene<'a, Message: 'a>(n: usize) -> Element<'a, Message, Theme, Renderer> {
|
||||||
fn layered_text<'a, Message: 'a>(
|
fn layered_text<'a, Message: 'a>(
|
||||||
n: usize,
|
n: usize,
|
||||||
) -> Element<'a, Message, Theme, Renderer> {
|
) -> Element<'a, Message, Theme, Renderer> {
|
||||||
stack((0..n).map(|i| text(format!("I am paragraph {i}!")).into()))
|
stack((0..n).map(|i| text!("I am paragraph {i}!").into()))
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
.height(Length::Fill)
|
.height(Length::Fill)
|
||||||
.into()
|
.into()
|
||||||
|
|
@ -215,13 +224,33 @@ fn dynamic_text<'a, Message: 'a>(
|
||||||
const LOREM_IPSUM: &str = include_str!("ipsum.txt");
|
const LOREM_IPSUM: &str = include_str!("ipsum.txt");
|
||||||
|
|
||||||
scrollable(
|
scrollable(
|
||||||
text(format!(
|
text!(
|
||||||
"{}... Iteration {i}",
|
"{}... Iteration {i}",
|
||||||
std::iter::repeat(LOREM_IPSUM.chars())
|
std::iter::repeat(LOREM_IPSUM.chars())
|
||||||
.flatten()
|
.flatten()
|
||||||
.take(n)
|
.take(n)
|
||||||
.collect::<String>(),
|
.collect::<String>(),
|
||||||
))
|
)
|
||||||
|
.size(10),
|
||||||
|
)
|
||||||
|
.into()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn advanced_shaping<'a, Message: 'a>(
|
||||||
|
n: usize,
|
||||||
|
i: usize,
|
||||||
|
) -> Element<'a, Message, Theme, Renderer> {
|
||||||
|
const LOREM_IPSUM: &str = include_str!("ipsum.txt");
|
||||||
|
|
||||||
|
scrollable(
|
||||||
|
text!(
|
||||||
|
"{}... Iteration {i} 😎",
|
||||||
|
std::iter::repeat(LOREM_IPSUM.chars())
|
||||||
|
.flatten()
|
||||||
|
.take(n)
|
||||||
|
.collect::<String>(),
|
||||||
|
)
|
||||||
|
.shaping(text::Shaping::Advanced)
|
||||||
.size(10),
|
.size(10),
|
||||||
)
|
)
|
||||||
.into()
|
.into()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue