Component params
This commit is contained in:
+15
-9
@@ -17,14 +17,7 @@ pub fn main() {
|
||||
|
||||
let handle = thread::spawn(move || {
|
||||
let res = engine
|
||||
.run(move |cx| {
|
||||
rsx! {
|
||||
for _ in (0..items) {
|
||||
"Hello, world!"
|
||||
}
|
||||
}
|
||||
.view(cx.clone())
|
||||
})
|
||||
.run(BenchmarkApp(items))
|
||||
.expect("Failed to run engine");
|
||||
|
||||
tx.send((items, res)).expect("Failed to send result");
|
||||
@@ -46,5 +39,18 @@ pub fn main() {
|
||||
for (items, bench) in results {
|
||||
println!("Results for {items} items:\n{bench}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
struct BenchmarkApp(pub usize);
|
||||
|
||||
impl ComponentImpl for BenchmarkApp {
|
||||
fn call(&self, cx: &Arc<Context>) -> View {
|
||||
let items = self.0.clone();
|
||||
rsx! {
|
||||
for _ in (0..items) {
|
||||
"Hello, world!"
|
||||
}
|
||||
}
|
||||
.view(cx.clone())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,16 @@ use osui::prelude::*;
|
||||
|
||||
pub fn main() {
|
||||
let engine = Console::new();
|
||||
engine.run(app).expect("Failed to run engine");
|
||||
engine.run(App).expect("Failed to run engine");
|
||||
}
|
||||
|
||||
fn app(cx: &Arc<Context>) -> View {
|
||||
rsx! {
|
||||
"Hello, world!"
|
||||
struct App;
|
||||
|
||||
impl ComponentImpl for App {
|
||||
fn call(&self, cx: &Arc<Context>) -> View {
|
||||
rsx! {
|
||||
"Hello, world!"
|
||||
}
|
||||
.view(cx.clone())
|
||||
}
|
||||
.view(cx.clone())
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ use osui::prelude::*;
|
||||
|
||||
pub fn main() {
|
||||
let engine = Benchmark::new(Console::new());
|
||||
let benchmark_result = engine.run(app).expect("Failed to run engine");
|
||||
let benchmark_result = engine.run(App).expect("Failed to run engine");
|
||||
println!("Avg: {} μs", benchmark_result.average);
|
||||
println!("Min: {} μs", benchmark_result.min);
|
||||
println!("Max: {} μs", benchmark_result.max);
|
||||
@@ -12,9 +12,13 @@ pub fn main() {
|
||||
println!("Tot Render: {} μs", benchmark_result.total_render);
|
||||
}
|
||||
|
||||
fn app(cx: &Arc<Context>) -> View {
|
||||
rsx! {
|
||||
"Hello, world!"
|
||||
struct App;
|
||||
|
||||
impl ComponentImpl for App {
|
||||
fn call(&self, cx: &Arc<Context>) -> View {
|
||||
rsx! {
|
||||
"Hello, world!"
|
||||
}
|
||||
.view(cx.clone())
|
||||
}
|
||||
.view(cx.clone())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user