Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions AutoQuery.sln
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoQueryApiDemo", "sample\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoQuery.AspNetCore.Tests", "test\AutoQuery.AspNetCore.Tests\AutoQuery.AspNetCore.Tests.csproj", "{A9125D44-3F97-4251-85F7-B28D07FA7B2D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sandbox", "sandbox", "{75B3287A-5C54-494A-B646-72CFBF9E2FB2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoQuery.Benchmark", "sandbox\AutoQuery.Benchmark\AutoQuery.Benchmark.csproj", "{6F332D4E-4C59-40C7-836F-C7344FD9ACD5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -56,6 +60,10 @@ Global
{A9125D44-3F97-4251-85F7-B28D07FA7B2D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9125D44-3F97-4251-85F7-B28D07FA7B2D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A9125D44-3F97-4251-85F7-B28D07FA7B2D}.Release|Any CPU.Build.0 = Release|Any CPU
{6F332D4E-4C59-40C7-836F-C7344FD9ACD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6F332D4E-4C59-40C7-836F-C7344FD9ACD5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6F332D4E-4C59-40C7-836F-C7344FD9ACD5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6F332D4E-4C59-40C7-836F-C7344FD9ACD5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -67,6 +75,7 @@ Global
{AEAB6CC3-1A1D-450D-A368-6A3BAF82A4DE} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{BF0093CA-57E3-4D5F-91B9-46898DFDD0C1} = {E97A2640-E7C7-4C4B-B3E2-311C1B9FDAA4}
{A9125D44-3F97-4251-85F7-B28D07FA7B2D} = {5730CC15-795B-43C9-802C-18B3E19B7E22}
{6F332D4E-4C59-40C7-836F-C7344FD9ACD5} = {75B3287A-5C54-494A-B646-72CFBF9E2FB2}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8FA10855-B537-4BAA-BB5B-6C0FB0BA6F42}
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
- **Pagination and Sorting**: Built-in support for pagination and sorting.
- **ASP.NET Core Integration**: Middleware support for easy integration into ASP.NET Core projects.

## Benchmark

The benchmark results provide an overview of `AutoQuery`'s performance in handling dynamic queries and filtering. These results can help evaluate its suitability for various application scenarios.

![](imgs/benchmarks.jpg)

## Installation

### AutoQuery
Expand Down
Binary file added imgs/benchmarks.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions sandbox/AutoQuery.Benchmark/AutoQuery.Benchmark.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.6.0.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\AutoQuery\AutoQuery.csproj" />
</ItemGroup>

</Project>
18 changes: 18 additions & 0 deletions sandbox/AutoQuery.Benchmark/BenchmarkConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Jobs;

namespace AutoQuery.Benchmark;

internal class BenchmarkConfig : ManualConfig
{
public BenchmarkConfig()
{
AddDiagnoser(MemoryDiagnoser.Default);
AddJob(Job.ShortRun
.WithWarmupCount(1)
.WithIterationCount(1)
.WithRuntime(CoreRuntime.Core80));
}
}
80 changes: 80 additions & 0 deletions sandbox/AutoQuery.Benchmark/Benchmarks/QueryPerformance.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using AutoQuery.Abstractions;
using AutoQuery.Extensions;
using BenchmarkDotNet.Attributes;
using System.Linq.Dynamic.Core;
using System.Reflection;

namespace AutoQuery.Benchmark.Benchmarks;

[Config(typeof(BenchmarkConfig))]
public class QueryPerformance
{
private List<TestData> _autoQueryTestData = null!;
private List<TestData> _dynamicLinqTestData = null!;
private QueryProcessor _queryProcessor = null!;

[GlobalSetup]
public void Setup()
{
_queryProcessor = new QueryProcessor();
_queryProcessor.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
_autoQueryTestData = Enumerable.Range(1, 10000)
.Select(i => new TestData { Id = i, Name = $"Name{i}", Age = i % 100 })
.ToList();
_dynamicLinqTestData = Enumerable.Range(1, 10000)
.Select(i => new TestData { Id = i, Name = $"Name{i}", Age = i % 100 })
.ToList();
}

[Benchmark]
public void FilterSortSelectPageWithAutoQuery()
{
var queryOptions = new TestQueryOptions
{
Name = "Name5000",
Sort = "Age",
Fields = "Id,Name",
Page = 1,
PageSize = 10
};

_autoQueryTestData.AsQueryable().ApplyQueryPaged(_queryProcessor, queryOptions);
}

[Benchmark]
public void FilterSortSelectPageWithDynamicLinq()
{
_dynamicLinqTestData.AsQueryable()
.Where("Name == @0", "Name5000")
.OrderBy("Age")
.Select("new (Id, Name)")
.Skip(0)
.Take(10)
.ToDynamicList();
}

public class UserQueryConfiguration : IFilterQueryConfiguration<TestQueryOptions, TestData>
{
public void Configure(FilterQueryBuilder<TestQueryOptions, TestData> builder)
{
builder.Property(q => q.Name, d => d.Name)
.HasEqual();
}
}

public class TestData
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public int Age { get; set; }
}

public class TestQueryOptions : IQueryPagedOptions
{
public string? Name { get; set; }
public string? Fields { get; set; }
public string? Sort { get; set; }
public int? Page { get; set; }
public int? PageSize { get; set; }
}
}
4 changes: 4 additions & 0 deletions sandbox/AutoQuery.Benchmark/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
using BenchmarkDotNet.Running;
using System.Reflection;

BenchmarkSwitcher.FromAssembly(Assembly.GetEntryAssembly()!).Run(args);