Skip to content

Commit

Permalink
Updated Benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
oruchreis committed Dec 12, 2023
1 parent 0c41ab4 commit b31a80c
Show file tree
Hide file tree
Showing 18 changed files with 1,916 additions and 1,773 deletions.
428 changes: 205 additions & 223 deletions README.md

Large diffs are not rendered by default.

45 changes: 31 additions & 14 deletions Tests/ReindexerNet.EmbeddedBenchmarks/BenchmarkEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Realms;
using Realms.Schema;
using Realms.Weaving;
using System.Linq.Expressions;
using System.Runtime.Serialization;
using System.Text.Json.Serialization;

Expand Down Expand Up @@ -32,49 +33,65 @@ public sealed class BenchmarkEntity

[ServerSideValue(Client.Core.IndexType.Dictionary)]
[DataMember(Order = 5)]
public string[] StrArray { get; set; }
public string[] StrArray { get; set; }

public BenchmarkEntity PreventLazy()
=> new BenchmarkEntity
{
Id = Id,
IntArray = IntArray.ToArray(),
StrArray = StrArray.ToArray(),
CreateDate = CreateDate,
IntProperty = IntProperty,
StringProperty = StringProperty,
};
}

public sealed partial class BenchmarkRealmEntity: IRealmObject
{
[PrimaryKey]
public sealed partial class BenchmarkRealmEntity : IRealmObject
{
[PrimaryKey]
public Guid Id { get; set; }

[Indexed(Realms.IndexType.General)]
[Indexed(Realms.IndexType.General)]
public int? IntProperty { get; set; }

[Indexed(Realms.IndexType.General)]
[Indexed(Realms.IndexType.General)]
public string? StringProperty { get; set; }

[Indexed(Realms.IndexType.General)]
[Indexed(Realms.IndexType.General)]
public DateTimeOffset? CreateDate { get; set; }

public ISet<int> IntArray { get; }

public ISet<string> StrArray { get; }

public static implicit operator BenchmarkEntity(BenchmarkRealmEntity realmEntity)
{
return new BenchmarkEntity{
return new BenchmarkEntity
{
Id = realmEntity.Id,
IntProperty = realmEntity.IntProperty,
StringProperty = realmEntity.StringProperty,
CreateDate = realmEntity.CreateDate,
IntArray = realmEntity.IntArray.ToArray(),
StrArray = realmEntity.StrArray.ToArray()
};
IntArray = [.. realmEntity.IntArray],
StrArray = [.. realmEntity.StrArray]
};
}

public static implicit operator BenchmarkRealmEntity(BenchmarkEntity realmEntity)
{
var entity = new BenchmarkRealmEntity{
var entity = new BenchmarkRealmEntity
{
Id = realmEntity.Id,
IntProperty = realmEntity.IntProperty,
StringProperty = realmEntity.StringProperty,
CreateDate = realmEntity.CreateDate,
};
};
entity.IntArray.UnionWith(realmEntity.IntArray);
entity.StrArray.UnionWith(realmEntity.StrArray);
return entity;
}

public BenchmarkEntity PreventLazy()
=> (BenchmarkEntity)this;
}
27 changes: 27 additions & 0 deletions Tests/ReindexerNet.EmbeddedBenchmarks/BenchmarkHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using ReindexerNet;
using ReindexerNetBenchmark.EmbeddedBenchmarks;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ReindexerNetBenchmark;

internal static class BenchmarkHelper
{
public static object CaptureResult(this BenchmarkEntity entity)
=> entity.PreventLazy();

public static object CaptureResult(this BenchmarkRealmEntity entity)
=> entity.PreventLazy();

public static object CaptureResult(this IEnumerable<BenchmarkEntity> entites)
=> entites.Select(e => e.PreventLazy()).ToList();

public static object CaptureResult(this IEnumerable<BenchmarkRealmEntity> entites)
=> entites.Select(e => e.PreventLazy()).ToList();

public static object CaptureResult(this QueryItemsOf<BenchmarkEntity> result)
=> result.Items.Select(e => e.PreventLazy()).ToList();
}
Loading

0 comments on commit b31a80c

Please sign in to comment.