performance

This commit is contained in:
Tim Schubert 2024-12-28 00:06:10 +01:00
parent 656ed32f8a
commit fe0eebe60d
Signed by: dadada
SSH key fingerprint: SHA256:bFAjFH3hR8zRBaJjzQDjc3o4jqoq5EZ87l+KXEjxIz0

View file

@ -1,41 +1,44 @@
#![no_main]
#![no_std]
use core::iter::repeat;
use core::{fmt::Write, iter::repeat};
use heapless::Vec;
use heapless::{String, Vec};
use log::info;
use system::with_stdout;
use uefi::{prelude::*, print, println};
use uefi::prelude::*;
#[entry]
fn main() -> Status {
uefi::helpers::init().unwrap();
info!("Hello world!");
const W: usize = 32;
const H: usize = 32;
const W: usize = 30;
const H: usize = 30;
let mut life: Vec<Vec<bool, W>, H> = life();
for (i, j) in [(15, 16), (16, 15), (16, 16), (17, 16), (17, 17)] {
life[i][j] = true;
}
for i in 0..100_000 {
with_stdout(|stdout| stdout.clear()).unwrap();
println!("Generation: {}", i);
for _i in 0..100_000 {
life = gol(life.clone());
let mut out: String<{ (W * H) + H }> = String::default();
for l in life.iter() {
for cell in l.iter() {
if *cell {
print!("X")
out.push('X').unwrap()
} else {
print!(" ")
out.push(' ').unwrap()
}
}
println!("");
out.push('\n').unwrap()
}
boot::stall(1_000);
with_stdout(|stdout| {
stdout.reset(true).unwrap();
stdout.write_str(&out).unwrap()
});
boot::stall(100_000);
}
boot::stall(100_000_000);