Skip to content

Commit

Permalink
version 2.0.0 - release (#20)
Browse files Browse the repository at this point in the history
* Add Gridify Compiled expression result to the benchmarks

* add some comments

* rename ApplyEverything to ApplyFilteringOrderingPaging

* update to v2.0.0
  • Loading branch information
alirezanet authored Sep 18, 2021
1 parent eb1f963 commit acc1508
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 19 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ The library adds below extension methods to `IQueryable`:
| ApplyOrdering | Apply ordering using `string OrderBy` and `bool IsSortAsc` properties of `GridifyQuery` class and returns an `IQueryable<T>` |
| ApplyPaging | Apply paging using `short Page` and `int PageSize` properties of `GridifyQuery` class and returns an `IQueryable<T>` |
| ApplyOrderingAndPaging | Apply both Ordering and paging and returns an `IQueryable<T>` |
| ApplyFilterAndOrdering | Apply both filtering and ordering and returns an `IQueryable<T>` |
| ApplyEverything | Apply filtering,ordering and paging and returns an `IQueryable<T>` |
| GridifyQueryable | Like ApplyEverything but it returns a `QueryablePaging<T>` that have an extra `int Count` property to use for pagination |
| ApplyFilteringAndOrdering | Apply both filtering and ordering and returns an `IQueryable<T>` |
| ApplyFilteringOrderingPaging | Apply filtering,ordering and paging and returns an `IQueryable<T>` |
| GridifyQueryable | Like `ApplyFilteringOrderingPaging` but it returns a `QueryablePaging<T>` that have an extra `int Count` property to use for pagination |
| Gridify | Receives a `GridifyQuery` , loads All requested data and returns `Paging<T>` |

**TIP**:
Expand Down
45 changes: 34 additions & 11 deletions benchmark/LibraryComparisionFilteringBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,29 @@ public class LibraryComparisionFilteringBenchmark
{
private static readonly Consumer Consumer = new();
private TestClass[] _data;
private Func<TestClass, bool> compiled1;
private Func<TestClass, bool> compiled2;
private Func<TestClass, bool> compiled3;

private IQueryable<TestClass> Ds => _data.AsQueryable();
private IEnumerable<TestClass> EnumerableDs => _data.ToList();

[GlobalSetup]
public void Setup()
{
_data = GetSampleData().ToArray();

// compiled query (this is not included in our readme benchmarks)
var gm = new GridifyMapper<TestClass>().GenerateMappings();
var gq1 = new GridifyQuery() {Filter = "Name=*a"};
var gq2 = new GridifyQuery() {Filter = "Id>5"};
var gq3 = new GridifyQuery() {Filter = "Name=Ali"};
compiled1 = gq1.GetFilteringExpression(gm).Compile();
compiled2 = gq2.GetFilteringExpression(gm).Compile();
compiled3 = gq3.GetFilteringExpression(gm).Compile();
}


[Benchmark(Baseline = true)]
public void NativeLinQ()
{
Expand All @@ -46,6 +61,14 @@ public void Gridify()
Ds.ApplyFiltering("Name=Ali").Consume(Consumer);
}

[Benchmark] // compiled query (this is not included in our readme benchmarks)w
public void GridifyCompiled()
{
EnumerableDs.Where(compiled1).Consume(Consumer);
EnumerableDs.Where(compiled2).Consume(Consumer);
EnumerableDs.Where(compiled3).Consume(Consumer);
}

[Benchmark]
public void Fop()
{
Expand All @@ -67,9 +90,9 @@ public void DynamicLinQ()
public void Sieve()
{
var processor = new SieveProcessor(new OptionsWrapper<SieveOptions>(new SieveOptions()));
processor.Apply(new SieveModel { Filters = "Name@=a" }, Ds, applySorting: false, applyPagination: false).Consume(Consumer);
processor.Apply(new SieveModel { Filters = "Id>5" }, Ds, applySorting: false, applyPagination: false).Consume(Consumer);
processor.Apply(new SieveModel { Filters = "Name==Ali" }, Ds, applySorting: false, applyPagination: false).Consume(Consumer);
processor.Apply(new SieveModel {Filters = "Name@=a"}, Ds, applySorting: false, applyPagination: false).Consume(Consumer);
processor.Apply(new SieveModel {Filters = "Id>5"}, Ds, applySorting: false, applyPagination: false).Consume(Consumer);
processor.Apply(new SieveModel {Filters = "Name==Ali"}, Ds, applySorting: false, applyPagination: false).Consume(Consumer);
}


Expand All @@ -78,21 +101,21 @@ private static IEnumerable<TestClass> GetSampleData()
var lst = new List<TestClass>();
lst.Add(new TestClass(1, "John", null, Guid.NewGuid(), DateTime.Now));
lst.Add(new TestClass(2, "Bob", null, Guid.NewGuid(), DateTime.UtcNow));
lst.Add(new TestClass(3, "Jack", (TestClass)lst[0].Clone(), Guid.Empty, DateTime.Now.AddDays(2)));
lst.Add(new TestClass(3, "Jack", (TestClass) lst[0].Clone(), Guid.Empty, DateTime.Now.AddDays(2)));
lst.Add(new TestClass(4, "Rose", null, Guid.Parse("e2cec5dd-208d-4bb5-a852-50008f8ba366")));
lst.Add(new TestClass(5, "Ali", null));
lst.Add(new TestClass(6, "Hamid", (TestClass)lst[0].Clone(), Guid.Parse("de12bae1-93fa-40e4-92d1-2e60f95b468c")));
lst.Add(new TestClass(7, "Hasan", (TestClass)lst[1].Clone()));
lst.Add(new TestClass(8, "Farhad", (TestClass)lst[2].Clone(), Guid.Empty));
lst.Add(new TestClass(6, "Hamid", (TestClass) lst[0].Clone(), Guid.Parse("de12bae1-93fa-40e4-92d1-2e60f95b468c")));
lst.Add(new TestClass(7, "Hasan", (TestClass) lst[1].Clone()));
lst.Add(new TestClass(8, "Farhad", (TestClass) lst[2].Clone(), Guid.Empty));
lst.Add(new TestClass(9, "Sara", null));
lst.Add(new TestClass(10, "Jorge", null));
lst.Add(new TestClass(11, "joe", null));
lst.Add(new TestClass(12, "jimmy", (TestClass)lst[0].Clone()));
lst.Add(new TestClass(12, "jimmy", (TestClass) lst[0].Clone()));
lst.Add(new TestClass(13, "Nazanin", null));
lst.Add(new TestClass(14, "Reza", null));
lst.Add(new TestClass(15, "Korosh", (TestClass)lst[0].Clone()));
lst.Add(new TestClass(16, "Kamran", (TestClass)lst[1].Clone()));
lst.Add(new TestClass(17, "Saeid", (TestClass)lst[2].Clone()));
lst.Add(new TestClass(15, "Korosh", (TestClass) lst[0].Clone()));
lst.Add(new TestClass(16, "Kamran", (TestClass) lst[1].Clone()));
lst.Add(new TestClass(17, "Saeid", (TestClass) lst[2].Clone()));
lst.Add(new TestClass(18, "jessi==ca", null));
lst.Add(new TestClass(19, "Ped=ram", null));
lst.Add(new TestClass(20, "Peyman!", null));
Expand Down
2 changes: 1 addition & 1 deletion src/Gridify.EntityFramework/Gridify.EntityFramework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageId>Gridify.EntityFramework</PackageId>
<Version>2.0.0-beta.3</Version>
<Version>2.0.0</Version>
<Authors>Alireza Sabouri</Authors>
<Company>TuxTeam</Company>
<PackageDescription>Gridify (EntityFramework), Easy and optimized way to apply Filtering, Sorting, and Pagination using text-based data.</PackageDescription>
Expand Down
2 changes: 1 addition & 1 deletion src/Gridify/Gridify.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageId>Gridify</PackageId>
<Version>2.0.0-beta.3</Version>
<Version>2.0.0</Version>
<Authors>Alireza Sabouri</Authors>
<Company>TuxTeam</Company>
<PackageDescription>Gridify, Easy and optimized way to apply Filtering, Sorting, and Pagination using text-based data.</PackageDescription>
Expand Down
4 changes: 2 additions & 2 deletions src/Gridify/GridifyExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static IGridifyMapper<T> FixMapper<T>(this IGridifyMapper<T>? mapper)
/// <param name="mapper">this is an optional parameter to apply filtering and ordering using a custom mapping configuration</param>
/// <typeparam name="T">type of target entity</typeparam>
/// <returns>returns user query after applying filtering, ordering and paging </returns>
public static IQueryable<T> ApplyEverything<T>(this IQueryable<T> query, IGridifyQuery? gridifyQuery, IGridifyMapper<T>? mapper = null)
public static IQueryable<T> ApplyFilteringOrderingPaging<T>(this IQueryable<T> query, IGridifyQuery? gridifyQuery, IGridifyMapper<T>? mapper = null)
{
if (gridifyQuery == null) return query;
mapper = mapper.FixMapper();
Expand Down Expand Up @@ -236,7 +236,7 @@ public static IQueryable<T> ApplyFiltering<T>(this IQueryable<T> query, string?
return query;
}

public static IQueryable<T> ApplyFilterAndOrdering<T>(this IQueryable<T> query, IGridifyQuery? gridifyQuery, IGridifyMapper<T>? mapper = null)
public static IQueryable<T> ApplyFilteringAndOrdering<T>(this IQueryable<T> query, IGridifyQuery? gridifyQuery, IGridifyMapper<T>? mapper = null)
{
mapper = mapper.FixMapper();
query = query.ApplyFiltering(gridifyQuery, mapper);
Expand Down
2 changes: 1 addition & 1 deletion test/Gridify.Tests/GridifyExtensionsShould.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public void ApplyEverything_EmptyGridifyQuery()
var gq = new GridifyQuery();

var actual = _fakeRepository.AsQueryable()
.ApplyEverything(gq)
.ApplyFilteringOrderingPaging(gq)
.ToList();

var expected = _fakeRepository.Skip(0).Take(GridifyExtensions.DefaultPageSize).ToList();
Expand Down

0 comments on commit acc1508

Please sign in to comment.