From 92717383db458293ae24dd35d15a086360d9d189 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 16 Oct 2019 00:11:04 +0200 Subject: [PATCH] Performance improvements. --- .../Log/JsonLogWriter.cs | 7 +---- src/Squidex.Shared/Users/UserExtensions.cs | 4 ++- src/Squidex/Config/Logging.cs | 28 ++++++++++--------- tools/LoadTest/ReadingBenchmarks.cs | 15 +++++++++- tools/LoadTest/ReadingFixture.cs | 5 ++++ 5 files changed, 38 insertions(+), 21 deletions(-) diff --git a/src/Squidex.Infrastructure/Log/JsonLogWriter.cs b/src/Squidex.Infrastructure/Log/JsonLogWriter.cs index a79108169..df5d950c8 100644 --- a/src/Squidex.Infrastructure/Log/JsonLogWriter.cs +++ b/src/Squidex.Infrastructure/Log/JsonLogWriter.cs @@ -207,12 +207,7 @@ namespace Squidex.Infrastructure.Log private static string Format(string property) { - if (ReferenceEquals(string.IsInterned(property), property)) - { - return property; - } - - return property.ToCamelCase(); + return property; } public override string ToString() diff --git a/src/Squidex.Shared/Users/UserExtensions.cs b/src/Squidex.Shared/Users/UserExtensions.cs index f8c28c51c..cc9adfd88 100644 --- a/src/Squidex.Shared/Users/UserExtensions.cs +++ b/src/Squidex.Shared/Users/UserExtensions.cs @@ -86,7 +86,9 @@ namespace Squidex.Shared.Users public static bool HasClaimValue(this IUser user, string type, string value) { - return user.Claims.Any(x => string.Equals(x.Type, type, StringComparison.OrdinalIgnoreCase) && string.Equals(x.Value, value, StringComparison.OrdinalIgnoreCase)); + return user.Claims.Any(x => + string.Equals(x.Type, type, StringComparison.OrdinalIgnoreCase) && + string.Equals(x.Value, value, StringComparison.OrdinalIgnoreCase)); } public static string PictureNormalizedUrl(this IUser user) diff --git a/src/Squidex/Config/Logging.cs b/src/Squidex/Config/Logging.cs index 42e3a0ecc..51c6a4ce9 100644 --- a/src/Squidex/Config/Logging.cs +++ b/src/Squidex/Config/Logging.cs @@ -18,23 +18,25 @@ namespace Squidex.Config { builder.AddFilter((category, level) => { - if (category.StartsWith("Orleans.Runtime.NoOpHostEnvironmentStatistics", StringComparison.OrdinalIgnoreCase)) + if (category.StartsWith("Orleans.", StringComparison.OrdinalIgnoreCase)) { - return level >= LogLevel.Error; - } + var subCategory = category.AsSpan().Slice(8); - if (category.StartsWith("Orleans.Runtime.SafeTimer", StringComparison.OrdinalIgnoreCase)) - { - return level >= LogLevel.Error; - } + if (subCategory.StartsWith("Runtime.")) + { + var subCategory2 = subCategory.Slice(8); - if (category.StartsWith("Orleans.Runtime.Scheduler", StringComparison.OrdinalIgnoreCase)) - { - return level >= LogLevel.Warning; - } + if (subCategory.StartsWith("NoOpHostEnvironmentStatistics", StringComparison.OrdinalIgnoreCase)) + { + return level >= LogLevel.Error; + } + + if (subCategory.StartsWith("SafeTimer", StringComparison.OrdinalIgnoreCase)) + { + return level >= LogLevel.Error; + } + } - if (category.StartsWith("Orleans.", StringComparison.OrdinalIgnoreCase)) - { return level >= LogLevel.Warning; } diff --git a/tools/LoadTest/ReadingBenchmarks.cs b/tools/LoadTest/ReadingBenchmarks.cs index e8a0cad7f..115628271 100644 --- a/tools/LoadTest/ReadingBenchmarks.cs +++ b/tools/LoadTest/ReadingBenchmarks.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Threading.Tasks; +using LoadTest.Model; using Squidex.ClientLibrary; using Xunit; @@ -35,11 +36,13 @@ namespace LoadTest int[] loads = { + 1, 5, 10, 20, 50, - 100 + 100, + 1000 }; foreach (var user in users) @@ -102,5 +105,15 @@ namespace LoadTest await Fixture.Client.GetAsync(new ODataQuery { Filter = "data/value/iv gt 3 and data/value/iv lt 7", OrderBy = "data/value/iv asc" }); }); } + + [Theory] + [MemberData(nameof(Loads))] + public async Task Should_return_clients(int numUsers, int numIterationsPerUser) + { + await Run.Parallel(numUsers, numIterationsPerUser, async () => + { + await Fixture.AppsClient.GetClientsAsync(TestClient.TestAppName); + }); + } } } diff --git a/tools/LoadTest/ReadingFixture.cs b/tools/LoadTest/ReadingFixture.cs index b8b7a2472..0187b15f3 100644 --- a/tools/LoadTest/ReadingFixture.cs +++ b/tools/LoadTest/ReadingFixture.cs @@ -9,6 +9,7 @@ using System; using System.Threading.Tasks; using LoadTest.Model; using Squidex.ClientLibrary; +using Squidex.ClientLibrary.Management; namespace LoadTest { @@ -16,6 +17,8 @@ namespace LoadTest { public SquidexClient Client { get; private set; } + public IAppsClient AppsClient { get; private set; } + public ReadingFixture() { Task.Run(async () => @@ -36,6 +39,8 @@ namespace LoadTest await Client.CreateAsync(new TestEntityData { Value = i }, true); } } + + AppsClient = TestClient.ClientManager.CreateAppsClient(); }).Wait(); }