use charton::error::ChartonError;
use charton::prelude::*;
use std::time::Instant;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let ds = get_10k_dataset()?;
let start = Instant::now();
Chart::build(ds)?
.mark_point()?
.encode((alt::x("x"), alt::y("y")))?
.with_title("Performance Test: 10,000 Points")
.save("stress_test.svg")?;
let duration = start.elapsed();
println!("--------------------------------------");
println!("渲染并保存 10,000 个点耗时: {:?}", duration);
println!("--------------------------------------");
Ok(())
}
pub fn get_10k_dataset() -> Result<Dataset, ChartonError> {
let count = 10_000;
let x: Vec<f64> = (0..count).map(|i| i as f64 * 0.01).collect();
let y: Vec<f64> = x.iter().map(|&val| val.sin()).collect();
let ds = Dataset::new().with_column("x", x)?.with_column("y", y)?;
Ok(ds)
}