From 99f050bc120e5d1804cf262b82a49720739d03b9 Mon Sep 17 00:00:00 2001 From: arnekeller Date: Tue, 9 Apr 2019 21:54:59 +0200 Subject: [PATCH] More debug output --- src/input.rs | 4 ++-- src/main.rs | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/input.rs b/src/input.rs index 695430a..83b6984 100644 --- a/src/input.rs +++ b/src/input.rs @@ -1,11 +1,11 @@ -use super::*; - use svgdom::{AttributeId, AttributeValue, Document, ElementId, FilterSvg, PathSegment, QName}; use std::error::Error; use std::io; use std::io::prelude::*; +use super::*; + pub(crate) struct InputData { pub start: Point, pub polys: Vec, diff --git a/src/main.rs b/src/main.rs index 654c3d8..63aeb0b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -121,6 +121,9 @@ fn main() { .flatten() .map(Point::from) .collect::>(); + if opt.debug { + eprintln!("DEBUG: {} Polygone mit {} Ecken", polys.len(), points.len()); + } // Startzustand: Lisa ist an ihrem Haus, zurückgelegte Distanz ist Null let start = RunState { @@ -143,6 +146,7 @@ fn main() { let mut iterations = 0; let mut time = time::Duration::from_secs(0); + let dijkstra_start = Instant::now(); // Dijkstra-Algorithmus anwenden let route = dijkstra( &start, @@ -200,7 +204,8 @@ fn main() { // Performanz-Einschätzung ausgeben if opt.debug { - eprintln!("{}us/iteration ({} iterations)", time.as_micros() / iterations, iterations) + eprintln!("DEBUG: {}us/iteration ({} iterations)", time.as_micros() / iterations, iterations); + eprintln!("DEBUG: {}ms total", (Instant::now() - dijkstra_start).as_millis()); } // beste Lösung ausgeben @@ -230,7 +235,7 @@ fn main() { .unwrap() + 1 ); } - eprintln!("x={:.02} y={:.02}", s.pos.x(), s.pos.y()); + eprintln!("x={:03.02} y={:03.02}", s.pos.x(), s.pos.y()); } eprintln!("Länge: {:.0}m", last.total_distance); let seconds = last.total_distance / lisa_speed;