More debug output

This commit is contained in:
arnekeller 2019-04-09 21:54:59 +02:00
parent f17dd4cb9a
commit 99f050bc12
2 changed files with 9 additions and 4 deletions

View File

@ -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<Polygon>,

View File

@ -121,6 +121,9 @@ fn main() {
.flatten()
.map(Point::from)
.collect::<Vec<_>>();
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;