From 64b8cad9538dcd6f49d6fb01daad69587d360ad3 Mon Sep 17 00:00:00 2001 From: fastium Date: Thu, 28 May 2026 17:57:50 +0200 Subject: [PATCH] feat(lab05): start report ex 3 --- doc/lab05-optimization/main.typ | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/doc/lab05-optimization/main.typ b/doc/lab05-optimization/main.typ index 3c14c43..9d95ba6 100644 --- a/doc/lab05-optimization/main.typ +++ b/doc/lab05-optimization/main.typ @@ -238,3 +238,34 @@ The same test was done with the `-01` compiler flag and there is almost no diffe == Exercise 3 +```bash +$ perf record --call-graph dwarf -e cpu-clock -F 75 ./read-apache-logs access_log_NASA_Jul95_samples +Couldn't synthesize bpf events. +Processing log file access_log_NASA_Jul95_samples +Found 14867 unique Hosts/IPs +[ perf record: Woken up 335 times to write data ] +[ perf record: Captured and wrote 83.687 MB perf.data (10269 samples) ] + +``` + +The only line were there is a comparison of 2 element with the `==` operator is : +```c +bool HostCounter::isNewHost(std::string hostname) +{ + return std::find(myHosts.begin(), myHosts.end(), hostname) == myHosts.end(); +} +``` + +The program check if the host is already in the vector. It shows that this operation on `vector` is slow. + +``` +# time ./read-apache-logs access_log_NASA_Jul95_samples +Processing log file access_log_NASA_Jul95_samples +Found 14867 unique Hosts/IPs +real 2m 15.58s +user 2m 14.68s +sys 0m 0.12s + +``` + +This collections library need to be transform in `set` collections to be faster. \ No newline at end of file