From 1e8e6f934c25c032097c961de2106334a9e889da Mon Sep 17 00:00:00 2001 From: Camill Hauser Date: Wed, 7 Feb 2024 13:46:52 +0100 Subject: [PATCH] keep timings sorted --- Classes/Utility/TimingUtility.php | 18 +++++++++++++----- ext_conf_template.txt | 8 ++++---- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Classes/Utility/TimingUtility.php b/Classes/Utility/TimingUtility.php index a78dc79..3140ac0 100644 --- a/Classes/Utility/TimingUtility.php +++ b/Classes/Utility/TimingUtility.php @@ -138,13 +138,21 @@ public function shutdown(ScriptResult $result): ?ResponseInterface } $timings = []; - foreach ($this->combineIfToMuch($this->order) as $index => $time) { - $duration = $time->getDuration(); - $timings[$duration . $index] = $this->timingString($index, trim($time->key . ' ' . $time->info . ' ' . $duration), $duration); + $durations = []; + $stopWatches = $this->combineIfToMuch($this->order); + + foreach ($stopWatches as $stopwatch) { + $durations[] = $stopwatch->getDuration(); } - krsort($timings); - $timings = array_slice($timings, 0, $this->configService->getMaxNumberOfTimings()); + rsort($durations); + + foreach ($stopWatches as $index => $time) { + $duration = $time->getDuration(); + if ($duration >= ($durations[$this->configService->getMaxNumberOfTimings() - 1] ?? 0)) { + $timings[] = $this->timingString($index, trim($time->key . ' ' . $time->info . ' ' . $duration), $duration); + } + } $headerString = implode(',', $timings); diff --git a/ext_conf_template.txt b/ext_conf_template.txt index ac630f7..de6f0f3 100644 --- a/ext_conf_template.txt +++ b/ext_conf_template.txt @@ -7,8 +7,8 @@ sentry_sample_rate = # cat=sentry; type=string; label=Sentry CLI Sample Rate between 0.0 and 1.0 (empty: keep default) sentry_cli_sample_rate = -# cat=sentry; type=integer; label=Number of timings -number_of_timings = +# cat=sentry; type=integer; label=Number of timings (reduce to make header output smaller. Try out when you get regularly 502 responses). +number_of_timings = 70 -# cat=sentry; type=integer; label=Length of description -length_of_description = +# cat=sentry; type=integer; label=Length of description (reduce to make header output smaller. Try out when you get regularly 502 responses). +length_of_description = 100