diff --git a/Cargo.toml b/Cargo.toml
index 0f642d3..564c3af 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,3 +13,4 @@ clap = { version = "4.4.13", features = ["derive"] }
rust_decimal = "1.34"
rust_decimal_macros = "1.34"
fast-float = "0.2"
+rustc-hash = { version = "1.0"}
diff --git a/flamegraphs/05-use-Fxhashmap/flamegraph.svg b/flamegraphs/05-use-Fxhashmap/flamegraph.svg
new file mode 100644
index 0000000..aaa3960
--- /dev/null
+++ b/flamegraphs/05-use-Fxhashmap/flamegraph.svg
@@ -0,0 +1,491 @@
+
\ No newline at end of file
diff --git a/src/main.rs b/src/main.rs
index 13d01cf..c04149d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,11 +1,11 @@
use clap::Parser;
use std::collections::BTreeMap;
-use std::collections::HashMap;
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
use std::time::Instant;
use fast_float;
+use rustc_hash::FxHashMap;
#[derive(Parser, Debug)]
#[command(
@@ -35,8 +35,8 @@ fn read_line(data: String) -> (String, f32) {
}
// Calculate the station values
-fn calculate_station_values(data: BufReader) -> HashMap {
- let mut result: HashMap = HashMap::new();
+fn calculate_station_values(data: BufReader) -> FxHashMap {
+ let mut result: FxHashMap = FxHashMap::default();
for line in data.lines() {
let line = line.expect("Failed to read line");
let (station_name, value) = read_line(line);
@@ -74,7 +74,7 @@ fn round_off(value: f32) -> f32 {
(value * 10.0).round() / 10.0
}
-fn write_result_stdout(result: HashMap) -> () {
+fn write_result_stdout(result: FxHashMap) -> () {
let mut ordered_result = BTreeMap::new();
for (station_name, station_values) in result {
ordered_result.insert(station_name, station_values);