Something went wrong. Try again.
HEXWORK - A Lantern in the Deep: 3D ASCII terminal roguelike RPG in Rust.
Entirely designed and built by Muse Spark 1.3 to evaluate if I like the model.
Something went wrong. Try again.
2.7 kB · 70 lines
Rust
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071//! Opt-in production (including derived light/descriptors) timing evidence.use crate::{ entry::render_production_scene, presentation_settings::PresentationPreferences, session::{GameSession, PlayerSetup},};use hexwork_core::character::{self, Ancestry, Calling};use hexwork_render::{ ansi::{self, ColorMode}, camera, scene::{RenderScratch, TacticalMapContext}, FrameBuffer,};
#[test]#[ignore = "optimized trajectory measurement; run explicitly with --ignored --nocapture"]fn render_trajectory_benchmark() { let session = GameSession::load( std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../.."), 140, PlayerSetup::new( "Render benchmark", character::new(Ancestry::Mudborn, Calling::Ratcatcher), ), ) .unwrap(); let context = session.tactical_context().unwrap(); let tactical = TacticalMapContext { min: context.bounds.min, max: context.bounds.max, player_cell: context.player_cell, }; let state = session.state().unwrap(); let pos = camera::voxel_center(context.player_cell.map(|v| v as f32)); let tuning = PresentationPreferences::default().render_tuning(); for (w, h) in [(80, 24), (120, 36)] { let mut frame = FrameBuffer::new(w, h); let mut scratch = RenderScratch::default(); let mut ansi = String::new(); let mut times = Vec::new(); for index in 0..110 { let yaw = -std::f32::consts::FRAC_PI_2 + (index % 20) as f32 * 0.025; let start = std::time::Instant::now(); let view = if index % 2 == 0 { camera::first_person(pos, yaw, 0.0) } else { camera::collision_safe_chase(&state.grid, pos, yaw, 1.5f32.atan2(3.0)) }; let landmarks = session.presentation_landmarks().unwrap(); render_production_scene( state, view, &tactical, &landmarks, &tuning, false, &mut frame, &mut scratch, ); ansi.clear(); ansi::encode_full_mode(&frame, &mut ansi, ColorMode::TrueColor); std::hint::black_box(&ansi); if index >= 10 { times.push(start.elapsed().as_secs_f64() * 1000.0); } } times.sort_by(f64::total_cmp); println!("production render+light+descriptors+gamma+full-TC {w}x{h}: n={} median_ms={:.3} p95_ms={:.3} target_ms=16.7 within_target={} allocations=UNMEASURED (light BTreeMap/descriptor Vec allocated per frame)",times.len(),times[50],times[94],times[94]<=16.7); }}