From 51cf8c275449229c2164441513d21b82c1c37801 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Sun, 7 Jul 2024 00:19:50 +0400 Subject: [PATCH] chore(style): fix code style --- src/Module/Frontend/Module/Profiler/ApiController.php | 2 +- src/Module/Frontend/Module/Profiler/Mapper.php | 2 +- tests/Unit/Module/Profiler/Struct/TreeTest.php | 11 ++++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Module/Frontend/Module/Profiler/ApiController.php b/src/Module/Frontend/Module/Profiler/ApiController.php index 7eb987e..faa18c8 100644 --- a/src/Module/Frontend/Module/Profiler/ApiController.php +++ b/src/Module/Frontend/Module/Profiler/ApiController.php @@ -59,7 +59,7 @@ public function profilerCallGraph( string $uuid, #[QueryParam] float $threshold = 1, #[QueryParam] float $percentage = 15, - #[QueryParam] string $metric = 'wt' + #[QueryParam] string $metric = 'wt', ): Message\CallGraph { $event = $this->eventsStorage->get($uuid) ?? throw new \RuntimeException('Event not found.'); diff --git a/src/Module/Frontend/Module/Profiler/Mapper.php b/src/Module/Frontend/Module/Profiler/Mapper.php index 6b66a66..897e477 100644 --- a/src/Module/Frontend/Module/Profiler/Mapper.php +++ b/src/Module/Frontend/Module/Profiler/Mapper.php @@ -48,7 +48,7 @@ public function topFunctions(Event $event, string $metric): TopFunctions 'mu' => static fn(Branch $a, Branch $b): int => $b->item->cost->mu <=> $a->item->cost->mu, 'pmu' => static fn(Branch $a, Branch $b): int => $b->item->cost->pmu <=> $a->item->cost->pmu, default => static fn(Branch $a, Branch $b): int => $b->item->cost->wt <=> $a->item->cost->wt, - } + }, ); foreach ($topBranches as $branch) { diff --git a/tests/Unit/Module/Profiler/Struct/TreeTest.php b/tests/Unit/Module/Profiler/Struct/TreeTest.php index 592961a..f803c3a 100644 --- a/tests/Unit/Module/Profiler/Struct/TreeTest.php +++ b/tests/Unit/Module/Profiler/Struct/TreeTest.php @@ -32,14 +32,14 @@ public function testTop(int $top): void static fn(Edge $edge) => $edge->caller, ); - $result = $tree->top($top, static fn(Branch $a,Branch $b) => $b->item->cost->wt <=> $a->item->cost->wt); + $result = $tree->top($top, static fn(Branch $a, Branch $b) => $b->item->cost->wt <=> $a->item->cost->wt); self::assertCount(\min($top, \count($edges)), $result); - $topUnoptimized = \array_map(static fn (Edge $e) => $e->cost->wt, $edges); + $topUnoptimized = \array_map(static fn(Edge $e) => $e->cost->wt, $edges); \rsort($topUnoptimized); $topUnoptimized = \array_slice($topUnoptimized, 0, $top); - $topVals = \array_map(static fn (Branch $b) => $b->item->cost->wt, $result); + $topVals = \array_map(static fn(Branch $b) => $b->item->cost->wt, $result); self::assertSame($topUnoptimized, $topVals); } @@ -53,9 +53,10 @@ private function generateEdges(int $multiplier = 20): array for ($i = 0; $i < $multiplier; $i++) { for ($j = 0; $j <= $i; $j++) { $result[] = new Edge( - $i === 0 ? null : 'item-' . ($i - 1) . "-$j", "item-$i-$j", + $i === 0 ? null : 'item-' . ($i - 1) . "-$j", + "item-$i-$j", new Cost( - ct: (int) $i**$i, + ct: (int) $i ** $i, wt: ($multiplier - $i) * 1000 + $j, cpu: ($multiplier - $i) * 10, mu: (int) $i * 1000,