100s for 1e9 records

This commit is contained in:
Aurel Feer 2024-08-18 11:28:14 +02:00
parent f2e04b3da0
commit 146a04c39a

View File

@ -20,7 +20,12 @@ fn main() {
let mut stations = HashMap::<String, Station>::new();
stations.reserve(10_000);
let mut line_no: usize = 0;
loop {
line_no += 1;
if line_no % 10_000_000 == 0 {
println!("{}", line_no);
}
line.clear();
let n = buffered_reader.read_line(&mut line).unwrap();
if n == 0 {
@ -50,7 +55,7 @@ fn main() {
stations.sort_unstable_by(|(n1, _), (n2, _)| n1.cmp(n2));
for (name, station) in stations {
assert!(!station.values.is_empty());
println!("{};{:1};{:1};{:1}", name,
println!("{};{:.1};{:.1};{:.1}", name,
station.values.iter().cloned().fold(100., f64::min),
station.values.iter().sum::<f64>() / station.values.len() as f64,
station.values.iter().cloned().fold(-100., f64::max))