-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: benchmark
- Loading branch information
Showing
5 changed files
with
8 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,4 @@ | ||
using BenchmarkDotNet.Columns; | ||
using BenchmarkDotNet.Configs; | ||
using BenchmarkDotNet.Loggers; | ||
using BenchmarkDotNet.Running; | ||
using BenchmarkDotNet.Validators; | ||
using BenchmarkDotNet.Running; | ||
using RESTCountries.NET.Benchmark; | ||
|
||
// CountryData.Standard is not optimized during build, | ||
// So to avoid benchmark errors, we need to disable the OptimizationValidator | ||
var config = new ManualConfig() | ||
.WithOptions(ConfigOptions.DisableOptimizationsValidator) | ||
.AddValidator(JitOptimizationsValidator.DontFailOnError) | ||
.AddLogger(ConsoleLogger.Default) | ||
.AddColumnProvider(DefaultColumnProviders.Instance); | ||
|
||
BenchmarkRunner.Run<RestCountriesServiceBenchmark>(config); | ||
BenchmarkRunner.Run<RestCountriesServiceBenchmark>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 2 additions & 26 deletions
28
tests/RESTCountries.NET.Benchmark/RestCountriesServiceBenchmark.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,14 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Columns; | ||
using BenchmarkDotNet.Configs; | ||
using BenchmarkDotNet.Jobs; | ||
using CountryData.Standard; | ||
using RESTCountries.NET.Services; | ||
using Country = RESTCountries.NET.Models.Country; | ||
using CountryDataCountry = CountryData.Standard.Country; | ||
using RESTCountries.NET.Models; | ||
|
||
namespace RESTCountries.NET.Benchmark; | ||
|
||
[MemoryDiagnoser] | ||
[MediumRunJob] | ||
[Config(typeof(Config))] | ||
public class RestCountriesServiceBenchmark | ||
{ | ||
private class Config : ManualConfig | ||
{ | ||
public Config() | ||
{ | ||
AddJob(Job.MediumRun); | ||
AddColumn(new TagColumn("Nuget", name => | ||
name.StartsWith("GetAll") ? "RESTCountries.NET 3.0.0" : "CountryData.Standard 1.3.0")); | ||
} | ||
} | ||
|
||
[Benchmark] | ||
[Arguments("RESTCountries.NET")] | ||
public List<Country> GetAllCountries() => RestCountriesService.GetAllCountries().ToList(); | ||
|
||
[Benchmark] | ||
[Arguments("CountryData.Standard")] | ||
public List<CountryDataCountry> GetCountryData() | ||
{ | ||
var helper = new CountryHelper(); | ||
return helper.GetCountryData().ToList(); | ||
} | ||
public List<Country> GetAllCountries() => RestCountriesService.GetAllCountries().ToList(); | ||
} |