From 5787f889d60a1659f2ed50005b7016ec305d8e16 Mon Sep 17 00:00:00 2001 From: Simon McKenna Date: Mon, 11 Mar 2024 18:05:14 +1030 Subject: [PATCH] Avoid unnecessary pre-flight checks --- Benchmarks.App/PreFlightCheck.cs | 9 ++++++--- Benchmarks.App/Program.cs | 11 ++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Benchmarks.App/PreFlightCheck.cs b/Benchmarks.App/PreFlightCheck.cs index 826d717..88b411f 100644 --- a/Benchmarks.App/PreFlightCheck.cs +++ b/Benchmarks.App/PreFlightCheck.cs @@ -2,9 +2,9 @@ internal static class PreFlightCheck { - internal static void CanStartTestContainers() + internal static void Run(bool isApp) { - ConsoleWriter.WriteHeader(clearConsole: false); + ConsoleWriter.WriteHeader(); AnsiConsole.MarkupLine("[gray]Running pre-flight check to verify test containers can start[/]"); AnsiConsole.WriteLine(); @@ -20,6 +20,9 @@ internal static void CanStartTestContainers() AnsiConsole.WriteLine(); AnsiConsole.MarkupLine("[gray]Test container pre-flight check passed[/]"); - Thread.Sleep(TimeSpan.FromSeconds(1.66)); + if (isApp) + { + Thread.Sleep(TimeSpan.FromSeconds(1.66)); + } } } diff --git a/Benchmarks.App/Program.cs b/Benchmarks.App/Program.cs index 4712e9a..c06405d 100644 --- a/Benchmarks.App/Program.cs +++ b/Benchmarks.App/Program.cs @@ -29,10 +29,15 @@ try { - // Do not run the preflight check if the user is asking for help or version information - if (args.Length > 0 && !args.Any(a => a.StartsWith('-'))) + var isPreFlightCheckNeeded = + (args.Length > 0 && !args.Any(arg => arg.StartsWith('-'))) && + args.Any(arg => + arg.Contains("app", StringComparison.OrdinalIgnoreCase) || + arg.Contains("benchmark", StringComparison.OrdinalIgnoreCase)); + if (isPreFlightCheckNeeded) { - PreFlightCheck.CanStartTestContainers(); + var isApp = args.Any(arg => arg.Contains("app", StringComparison.OrdinalIgnoreCase)); + PreFlightCheck.Run(isApp); } return await app.RunAsync(args);