From d6b141d1f026db678e6bf4be1f3bc6fb9a008b64 Mon Sep 17 00:00:00 2001 From: jvyden Date: Mon, 18 Oct 2021 22:42:16 -0400 Subject: [PATCH] log startup timings --- ProjectLighthouse/Program.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ProjectLighthouse/Program.cs b/ProjectLighthouse/Program.cs index 11b81681..ae45cb0e 100644 --- a/ProjectLighthouse/Program.cs +++ b/ProjectLighthouse/Program.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using Microsoft.AspNetCore.Hosting; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Hosting; @@ -7,17 +8,26 @@ using ProjectLighthouse.Types; namespace ProjectLighthouse { public static class Program { public static void Main(string[] args) { + Stopwatch startupStopwatch = new(); + startupStopwatch.Start(); Console.WriteLine("Welcome to Project Lighthouse!"); + Console.WriteLine("Determining if the database is available..."); bool dbConnected = ServerSettings.DbConnected; Console.WriteLine(dbConnected ? "Connected to the database." : "Database unavailable. Exiting."); if(dbConnected) { + Stopwatch migrationStopwatch = new(); + migrationStopwatch.Start(); + Console.WriteLine("Migrating database..."); new Database().Database.Migrate(); - } - else { - Environment.Exit(1); - } + + migrationStopwatch.Stop(); + Console.WriteLine($"Migration took {migrationStopwatch.ElapsedMilliseconds}ms"); + } else Environment.Exit(1); + + startupStopwatch.Stop(); + Console.WriteLine($"Ready! Startup took {startupStopwatch.ElapsedMilliseconds}ms. Passing off control to ASP.NET..."); CreateHostBuilder(args).Build().Run(); }