performance
This commit is contained in:
parent
656ed32f8a
commit
fe0eebe60d
1 changed files with 15 additions and 12 deletions
27
src/main.rs
27
src/main.rs
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue