Created
December 18, 2022 12:48
-
-
Save gistlyn/a7c55a56842899a1ce34f11456027a9b to your computer and use it in GitHub Desktop.
bench-audit
This file contains hidden or 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
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<TargetFramework>net6.0</TargetFramework> | |
<Nullable>enable</Nullable> | |
<ImplicitUsings>enable</ImplicitUsings> | |
<OutputType>Exe</OutputType> | |
<NoWarn>1591</NoWarn> | |
</PropertyGroup> | |
<ItemGroup> | |
<PackageReference Include="ServiceStack.Common" Version="6.*" /> | |
<PackageReference Include="ServiceStack.OrmLite.Sqlite" Version="6.*" /> | |
</ItemGroup> | |
</Project> |
This file contains hidden or 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
using System.Linq; | |
using System.Diagnostics; | |
using ServiceStack; | |
using ServiceStack.Text; | |
using ServiceStack.OrmLite; | |
using ServiceStack.DataAnnotations; | |
var dbFactory = new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider); | |
using var db = dbFactory.Open(); | |
db.CreateTable<Record>(); | |
for (int i = 0; i < 100; i++) | |
{ | |
db.Insert(new Record | |
{ | |
Name = $"Name {i}" , | |
CreatedBy = "TEST", | |
ModifiedBy = "TEST", | |
CreatedDate = DateTime.Now.ToUnixTimeMs(), | |
ModifiedDate = DateTime.Now.ToUnixTimeMs() | |
}); | |
} | |
var sw = new Stopwatch(); | |
sw.Start(); | |
var records = db.Select<Record>(); | |
var loadTime = sw.ElapsedMilliseconds; | |
Console.WriteLine($"Took {loadTime}ms to load {records.Count} records"); | |
public class Record //: AuditBase | |
{ | |
[PrimaryKey] | |
[AutoIncrement] | |
public int Id { get; set; } | |
public string Name { get; set; } | |
public string CreatedBy { get; set; } | |
public long CreatedDate { get; set; } | |
public string ModifiedBy { get; set; } | |
public long ModifiedDate { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment