From 6c59e4fceeb4fcdda37ff26e4bf8b8edad7707cf Mon Sep 17 00:00:00 2001 From: martincostello Date: Wed, 7 Aug 2024 08:15:25 +0100 Subject: [PATCH] Simplify benchmarks - Remove need for custom configuration now that `UseArtifactsOutput` is supported. - Use collection expression. - Simplify class declaration. --- .../CustomBenchmarkConfig.cs | 21 ------------------- .../GitHubJsonSerializerContext.cs | 4 +--- .../InterceptionBenchmarks.cs | 6 ++++-- 3 files changed, 5 insertions(+), 26 deletions(-) delete mode 100644 tests/HttpClientInterception.Benchmarks/CustomBenchmarkConfig.cs diff --git a/tests/HttpClientInterception.Benchmarks/CustomBenchmarkConfig.cs b/tests/HttpClientInterception.Benchmarks/CustomBenchmarkConfig.cs deleted file mode 100644 index 21ebca40..00000000 --- a/tests/HttpClientInterception.Benchmarks/CustomBenchmarkConfig.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Just Eat, 2017. All rights reserved. -// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information. - -using BenchmarkDotNet.Configs; -using BenchmarkDotNet.Diagnosers; -using BenchmarkDotNet.Jobs; - -namespace JustEat.HttpClientInterception; - -public class CustomBenchmarkConfig : ManualConfig -{ - public CustomBenchmarkConfig() - : base() - { - var job = Job.Default.WithArguments([new MsBuildArgument("/p:UseArtifactsOutput=false")]); - - AddJob(job); - AddDiagnoser(MemoryDiagnoser.Default); - AddDiagnoser(new EventPipeProfiler(EventPipeProfile.CpuSampling)); - } -} diff --git a/tests/HttpClientInterception.Benchmarks/GitHubJsonSerializerContext.cs b/tests/HttpClientInterception.Benchmarks/GitHubJsonSerializerContext.cs index 90604c81..4bb71083 100644 --- a/tests/HttpClientInterception.Benchmarks/GitHubJsonSerializerContext.cs +++ b/tests/HttpClientInterception.Benchmarks/GitHubJsonSerializerContext.cs @@ -7,7 +7,5 @@ namespace JustEat.HttpClientInterception; [JsonSerializable(typeof(GitHubOrganization))] -internal sealed partial class GitHubJsonSerializerContext : JsonSerializerContext -{ -} +internal sealed partial class GitHubJsonSerializerContext : JsonSerializerContext; #endif diff --git a/tests/HttpClientInterception.Benchmarks/InterceptionBenchmarks.cs b/tests/HttpClientInterception.Benchmarks/InterceptionBenchmarks.cs index ee3729c7..1fdd96bc 100644 --- a/tests/HttpClientInterception.Benchmarks/InterceptionBenchmarks.cs +++ b/tests/HttpClientInterception.Benchmarks/InterceptionBenchmarks.cs @@ -4,11 +4,13 @@ using System.Net.Http.Json; using System.Text.Json; using BenchmarkDotNet.Attributes; +using BenchmarkDotNet.Diagnosers; using Refit; namespace JustEat.HttpClientInterception; -[Config(typeof(CustomBenchmarkConfig))] +[EventPipeProfiler(EventPipeProfile.CpuSampling)] +[MemoryDiagnoser] public class InterceptionBenchmarks { private readonly HttpClientInterceptorOptions _options; @@ -40,7 +42,7 @@ public InterceptionBenchmarks() .ForQuery(string.Empty) .Responds() .WithMediaType("application/octet-stream") - .WithContent(() => new byte[] { 0, 1, 2, 3, 4 }) + .WithContent(() => [0, 1, 2, 3, 4]) .RegisterWith(_options); builder