From 561aedc7215e26f202987dc75e9889529667ff0e Mon Sep 17 00:00:00 2001 From: Simon <63975668+Simyon264@users.noreply.github.com> Date: Thu, 11 Apr 2024 20:22:35 +0200 Subject: [PATCH] Include better timing for debugging purposes. --- Server/ReplayParser.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Server/ReplayParser.cs b/Server/ReplayParser.cs index d92105e..05e6962 100644 --- a/Server/ReplayParser.cs +++ b/Server/ReplayParser.cs @@ -1,4 +1,5 @@ -using System.Globalization; +using System.Diagnostics; +using System.Globalization; using System.IO.Compression; using System.Text.RegularExpressions; using HtmlAgilityPack; @@ -296,8 +297,10 @@ public static HttpClient CreateHttpClient() /// public static (List, int) SearchReplays(SearchMode mode, string query, ReplayDbContext context, int page, int pageSize) { + var stopWatch = new Stopwatch(); + stopWatch.Start(); var queryable = context.Replays.AsQueryable(); - + IIncludableQueryable? players; IQueryable? replayIds; switch (mode) @@ -349,12 +352,16 @@ public static (List, int) SearchReplays(SearchMode mode, string query, R var totalItems = queryable.Count(); // Apply pagination on the database query - return (queryable + var list = (queryable .Include(r => r.RoundEndPlayers) .OrderByDescending(r => r.Date ?? DateTime.MinValue).Take(Constants.SearchLimit).ToList() .Skip(page * pageSize) .Take(pageSize) .ToList(), totalItems); + + stopWatch.Stop(); + Log.Information("Search took " + stopWatch.ElapsedMilliseconds + "ms."); + return list; } }