Last active
December 18, 2022 12:52
-
-
Save gistlyn/fe8d04617ee1b061f24b0d8d56948119 to your computer and use it in GitHub Desktop.
bench-audit
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
<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 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.Diagnostics; | |
using ServiceStack; | |
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, | |
ModifiedDate = DateTime.Now | |
}); | |
} | |
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; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment