Skip to content

Instantly share code, notes, and snippets.

@itn3000
Last active April 23, 2018 14:58
Show Gist options
  • Select an option

  • Save itn3000/b4468ce1825ff556e66a0febcdc95d35 to your computer and use it in GitHub Desktop.

Select an option

Save itn3000/b4468ce1825ff556e66a0febcdc95d35 to your computer and use it in GitHub Desktop.
litedb async wrapper
using System;
namespace litedbtest
{
using LiteDB;
using BenchmarkDotNet;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using System.Linq;
using System.Collections.Generic;
using System.Collections.Concurrent;
class MyEntity
{
public long Id { get; set; }
public int X { get; set; }
public string Y { get; set; }
}
struct LiteDbTask
{
public TaskCompletionSource<int> Completion;
public Action<LiteDatabase, LiteTransaction> TaskAction;
}
class AsyncLiteDbWrapper : IDisposable
{
object m_QueueLockObject = new object();
bool m_LeaveOpen;
LiteDatabase m_Database;
Thread m_Thread;
ConcurrentQueue<LiteDbTask> m_Queue = new ConcurrentQueue<LiteDbTask>();
ManualResetEventSlim m_QueueArrived = new ManualResetEventSlim(false);
ManualResetEventSlim m_Terminated = new ManualResetEventSlim(false);
public AsyncLiteDbWrapper(LiteDatabase db, bool leaveOpen = false)
{
m_Database = db;
m_LeaveOpen = leaveOpen;
m_Thread = new Thread(() =>
{
ThreadLoop();
});
m_Thread.Start();
}
public Task DoAction(Action<LiteDatabase, LiteTransaction> taskAction)
{
return Enqueue(taskAction);
}
private Task Enqueue(Action<LiteDatabase, LiteTransaction> taskAction)
{
lock (m_QueueLockObject)
{
var t = new LiteDbTask()
{
TaskAction = taskAction
,
Completion = new TaskCompletionSource<int>()
};
m_Queue.Enqueue(t);
m_QueueArrived.Set();
return t.Completion.Task;
}
}
private void ThreadLoop()
{
var whandles = new WaitHandle[] { m_QueueArrived.WaitHandle, m_Terminated.WaitHandle };
var buf = new List<LiteDbTask>(128);
var successed = new List<LiteDbTask>(128);
var failed = new List<(LiteDbTask, Exception)>(128);
while (true)
{
var enabledIndex = WaitHandle.WaitAny(whandles);
if (enabledIndex == 1)
{
break;
}
buf.Clear();
successed.Clear();
failed.Clear();
var objs = buf;
lock (m_QueueLockObject)
{
LiteDbTask obj;
while (true)
{
if (objs.Count > 100)
{
break;
}
if (m_Queue.TryDequeue(out obj))
{
objs.Add(obj);
}
else
{
// reset when queue is empty
m_QueueArrived.Reset();
break;
}
}
}
if (objs.Count > 0)
{
LiteTransaction tran;
tran = m_Database.BeginTrans();
bool terminated = false;
foreach (var t in objs)
{
if (terminated || m_Terminated.IsSet)
{
terminated = true;
t.Completion.TrySetCanceled();
}
else
{
try
{
t.TaskAction(m_Database, tran);
successed.Add(t);
// t.Completion.TrySetResult(0);
}
catch (LiteException e)
{
// if litedb exception, cancel successful tasks
tran.Dispose();
tran = m_Database.BeginTrans();
foreach(var ts in successed)
{
failed.Add((ts, e));
}
successed.Clear();
failed.Add((t, e));
}
catch (Exception e)
{
failed.Add((t, e));
// t.Completion.TrySetException(e);
}
}
}
tran?.Commit();
tran?.Dispose();
foreach (var t in successed)
{
t.Completion.TrySetResult(0);
}
foreach (var (t, ex) in failed)
{
t.Completion.TrySetException(ex);
}
}
}
}
#region IDisposable Support
private bool disposedValue = false; // To detect redundant calls
protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
if (m_Thread != null)
{
m_Terminated?.Set();
m_Thread.Join();
m_Thread = null;
}
if (m_Terminated != null)
{
m_Terminated.Dispose();
m_Terminated = null;
}
if (m_QueueArrived != null)
{
m_QueueArrived.Dispose();
m_QueueArrived = null;
}
if (!m_LeaveOpen && m_Database != null)
{
m_Database.Dispose();
m_Database = null;
}
}
disposedValue = true;
}
}
// This code added to correctly implement the disposable pattern.
public void Dispose()
{
// Do not change this code. Put cleanup code in Dispose(bool disposing) above.
Dispose(true);
// TODO: uncomment the following line if the finalizer is overridden above.
// GC.SuppressFinalize(this);
}
#endregion
}
public class LiteDbBench
{
static Lazy<LiteDatabase> m_Database = new Lazy<LiteDatabase>(new LiteDatabase("mydata.db"));
static long CurrentId = 0;
[Benchmark]
public void InsertMany()
{
var db = m_Database.Value;
const int MaxLoop = 100;
const int clientNum = 10;
using (var wrapper = new AsyncLiteDbWrapper(db, true))
{
Task.WhenAll(
Enumerable.Range(0, clientNum).Select(async (client) =>
{
await Task.Yield();
await wrapper.DoAction((x, tran) =>
{
var collection = x.GetCollection<MyEntity>();
for (int i = 0; i < MaxLoop / clientNum; i++)
{
var id = Interlocked.Increment(ref CurrentId);
collection.Insert(new MyEntity()
{
Id = id,
X = i,
Y = $"string{i},{id}"
});
}
}).ConfigureAwait(false);
return client;
})
).Wait();
}
}
}
class Program
{
static void Main(string[] args)
{
if (File.Exists("mydata.db"))
{
File.Delete("mydata.db");
}
if (File.Exists("mydata-journal.db"))
{
File.Delete("mydata-journal.db");
}
var summary = BenchmarkRunner.Run<LiteDbBench>();
// var sw = new System.Diagnostics.Stopwatch();
// sw.Start();
// new LiteDbBench().InsertMany();
// sw.Stop();
// Console.WriteLine($"{sw.Elapsed}");
}
}
}
// ***** BenchmarkRunner: Start *****
// Found benchmarks:
// LiteDbBench.InsertMany: DefaultJob
// Validating benchmarks:
// **************************
// Benchmark: LiteDbBench.InsertMany: DefaultJob
// *** Generate ***
// Result = Success
// BinariesDirectoryPath = G:\src\gitrepos\dotnet-sandbox\litedbtest\bin\Release\netcoreapp2.0\BDN.Generated\bin\Release\netcoreapp2.0
// *** Build ***
// dotnet restore took 1.71s
// dotnet build took 2.89s
// Result = Success
// *** Execute ***
// Launch: 1 / 1
// Benchmark Process Environment Information:
// Runtime=.NET Core 4.6.25302.01, 64bit RyuJIT
// GC=Concurrent Workstation
// Job: DefaultJob
Pilot 1: 16 op, 3109058334.14 ns, 194.3161 ms/op
IdleWarmup 1: 16 op, 14188.08 ns, 886.7550 ns/op
IdleWarmup 2: 16 op, 1207.50 ns, 75.4685 ns/op
IdleWarmup 3: 16 op, 1207.50 ns, 75.4685 ns/op
IdleWarmup 4: 16 op, 1207.50 ns, 75.4685 ns/op
IdleWarmup 5: 16 op, 1207.50 ns, 75.4685 ns/op
IdleWarmup 6: 16 op, 1207.50 ns, 75.4685 ns/op
IdleTarget 1: 16 op, 1207.50 ns, 75.4685 ns/op
IdleTarget 2: 16 op, 1509.37 ns, 94.3356 ns/op
IdleTarget 3: 16 op, 905.62 ns, 56.6014 ns/op
IdleTarget 4: 16 op, 905.62 ns, 56.6014 ns/op
IdleTarget 5: 16 op, 603.75 ns, 37.7343 ns/op
IdleTarget 6: 16 op, 301.87 ns, 18.8671 ns/op
IdleTarget 7: 16 op, 603.75 ns, 37.7343 ns/op
IdleTarget 8: 16 op, 603.75 ns, 37.7343 ns/op
IdleTarget 9: 16 op, 603.75 ns, 37.7343 ns/op
IdleTarget 10: 16 op, 603.75 ns, 37.7343 ns/op
IdleTarget 11: 16 op, 603.75 ns, 37.7343 ns/op
IdleTarget 12: 16 op, 603.75 ns, 37.7343 ns/op
IdleTarget 13: 16 op, 905.62 ns, 56.6014 ns/op
IdleTarget 14: 16 op, 603.75 ns, 37.7343 ns/op
IdleTarget 15: 16 op, 603.75 ns, 37.7343 ns/op
IdleTarget 16: 16 op, 301.87 ns, 18.8671 ns/op
IdleTarget 17: 16 op, 301.87 ns, 18.8671 ns/op
IdleTarget 18: 16 op, 301.87 ns, 18.8671 ns/op
IdleTarget 19: 16 op, 301.87 ns, 18.8671 ns/op
IdleTarget 20: 16 op, 905.62 ns, 56.6014 ns/op
MainWarmup 1: 16 op, 3572056728.17 ns, 223.2535 ms/op
MainWarmup 2: 16 op, 3177997005.41 ns, 198.6248 ms/op
MainWarmup 3: 16 op, 3105443694.46 ns, 194.0902 ms/op
MainWarmup 4: 16 op, 3085827014.10 ns, 192.8642 ms/op
MainWarmup 5: 16 op, 3598039328.15 ns, 224.8775 ms/op
MainWarmup 6: 16 op, 3280299700.54 ns, 205.0187 ms/op
MainWarmup 7: 16 op, 3258727480.20 ns, 203.6705 ms/op
MainWarmup 8: 16 op, 3255472674.36 ns, 203.4670 ms/op
MainWarmup 9: 16 op, 3404411587.13 ns, 212.7757 ms/op
MainWarmup 10: 16 op, 3300260517.29 ns, 206.2663 ms/op
MainTarget 1: 16 op, 3276351791.92 ns, 204.7720 ms/op
MainTarget 2: 16 op, 3676618648.57 ns, 229.7887 ms/op
MainTarget 3: 16 op, 3269415632.24 ns, 204.3385 ms/op
MainTarget 4: 16 op, 3021934771.06 ns, 188.8709 ms/op
MainTarget 5: 16 op, 3022636326.31 ns, 188.9148 ms/op
MainTarget 6: 16 op, 3304132051.78 ns, 206.5083 ms/op
MainTarget 7: 16 op, 3061526154.37 ns, 191.3454 ms/op
MainTarget 8: 16 op, 2829643728.27 ns, 176.8527 ms/op
MainTarget 9: 16 op, 3479442076.41 ns, 217.4651 ms/op
MainTarget 10: 16 op, 3297049483.19 ns, 206.0656 ms/op
MainTarget 11: 16 op, 3419246582.79 ns, 213.7029 ms/op
MainTarget 12: 16 op, 3510775393.64 ns, 219.4235 ms/op
MainTarget 13: 16 op, 3510152023.76 ns, 219.3845 ms/op
MainTarget 14: 16 op, 3013517013.62 ns, 188.3448 ms/op
MainTarget 15: 16 op, 3385602721.70 ns, 211.6002 ms/op
MainTarget 16: 16 op, 3250441037.96 ns, 203.1526 ms/op
MainTarget 17: 16 op, 3353277748.26 ns, 209.5799 ms/op
MainTarget 18: 16 op, 4240396783.23 ns, 265.0248 ms/op
MainTarget 19: 16 op, 3843840562.21 ns, 240.2400 ms/op
MainTarget 20: 16 op, 4331623418.18 ns, 270.7265 ms/op
MainTarget 21: 16 op, 3365892762.27 ns, 210.3683 ms/op
MainTarget 22: 16 op, 4318921464.45 ns, 269.9326 ms/op
MainTarget 23: 16 op, 3730197365.24 ns, 233.1373 ms/op
MainTarget 24: 16 op, 3883250519.22 ns, 242.7032 ms/op
MainTarget 25: 16 op, 3524600620.65 ns, 220.2875 ms/op
MainTarget 26: 16 op, 3315632244.98 ns, 207.2270 ms/op
MainTarget 27: 16 op, 2883006605.00 ns, 180.1879 ms/op
MainTarget 28: 16 op, 2912816062.11 ns, 182.0510 ms/op
MainTarget 29: 16 op, 3441889852.20 ns, 215.1181 ms/op
MainTarget 30: 16 op, 3175136748.94 ns, 198.4460 ms/op
MainTarget 31: 16 op, 3421598181.51 ns, 213.8499 ms/op
MainTarget 32: 16 op, 2733258066.07 ns, 170.8286 ms/op
MainTarget 33: 16 op, 2662678105.68 ns, 166.4174 ms/op
MainTarget 34: 16 op, 3072433165.09 ns, 192.0271 ms/op
MainTarget 35: 16 op, 3263000507.15 ns, 203.9375 ms/op
MainTarget 36: 16 op, 3197695191.75 ns, 199.8559 ms/op
MainTarget 37: 16 op, 3342485147.80 ns, 208.9053 ms/op
MainTarget 38: 16 op, 3513276721.89 ns, 219.5798 ms/op
MainTarget 39: 16 op, 3185197908.62 ns, 199.0749 ms/op
MainTarget 40: 16 op, 3175944261.98 ns, 198.4965 ms/op
MainTarget 41: 16 op, 3025002113.12 ns, 189.0626 ms/op
MainTarget 42: 16 op, 3233046754.25 ns, 202.0654 ms/op
MainTarget 43: 16 op, 3170740859.25 ns, 198.1713 ms/op
MainTarget 44: 16 op, 3194739844.96 ns, 199.6712 ms/op
MainTarget 45: 16 op, 3428390951.02 ns, 214.2744 ms/op
MainTarget 46: 16 op, 2956617380.70 ns, 184.7886 ms/op
MainTarget 47: 16 op, 3716766989.47 ns, 232.2979 ms/op
MainTarget 48: 16 op, 3097460937.50 ns, 193.5913 ms/op
MainTarget 49: 16 op, 2886628187.79 ns, 180.4143 ms/op
MainTarget 50: 16 op, 2985385070.52 ns, 186.5866 ms/op
MainTarget 51: 16 op, 3077817994.11 ns, 192.3636 ms/op
MainTarget 52: 16 op, 3182355462.71 ns, 198.8972 ms/op
MainTarget 53: 16 op, 3587743612.35 ns, 224.2340 ms/op
MainTarget 54: 16 op, 3463126992.37 ns, 216.4454 ms/op
MainTarget 55: 16 op, 3578017230.97 ns, 223.6261 ms/op
MainTarget 56: 16 op, 3253870326.99 ns, 203.3669 ms/op
MainTarget 57: 16 op, 3293628344.76 ns, 205.8518 ms/op
MainTarget 58: 16 op, 3153967228.55 ns, 197.1230 ms/op
MainTarget 59: 16 op, 3403995906.59 ns, 212.7497 ms/op
MainTarget 60: 16 op, 2891866909.78 ns, 180.7417 ms/op
MainTarget 61: 16 op, 2830830395.09 ns, 176.9269 ms/op
MainTarget 62: 16 op, 3075859435.37 ns, 192.2412 ms/op
MainTarget 63: 16 op, 3405508899.25 ns, 212.8443 ms/op
MainTarget 64: 16 op, 2883398135.63 ns, 180.2124 ms/op
MainTarget 65: 16 op, 3344388765.46 ns, 209.0243 ms/op
MainTarget 66: 16 op, 3467022676.78 ns, 216.6889 ms/op
MainTarget 67: 16 op, 2992176934.41 ns, 187.0111 ms/op
MainTarget 68: 16 op, 3000386700.64 ns, 187.5242 ms/op
MainTarget 69: 16 op, 3301327340.13 ns, 206.3330 ms/op
MainTarget 70: 16 op, 3342397302.45 ns, 208.8998 ms/op
MainTarget 71: 16 op, 3229188804.10 ns, 201.8243 ms/op
MainTarget 72: 16 op, 3092872150.31 ns, 193.3045 ms/op
MainTarget 73: 16 op, 3386192885.43 ns, 211.6371 ms/op
MainTarget 74: 16 op, 3361273183.93 ns, 210.0796 ms/op
MainTarget 75: 16 op, 3143892484.54 ns, 196.4933 ms/op
MainTarget 76: 16 op, 3054206916.54 ns, 190.8879 ms/op
MainTarget 77: 16 op, 3384096068.39 ns, 211.5060 ms/op
MainTarget 78: 16 op, 3202144513.14 ns, 200.1340 ms/op
MainTarget 79: 16 op, 3469414726.62 ns, 216.8384 ms/op
MainTarget 80: 16 op, 3687212615.92 ns, 230.4508 ms/op
MainTarget 81: 16 op, 3434847734.74 ns, 214.6780 ms/op
MainTarget 82: 16 op, 2942399415.57 ns, 183.9000 ms/op
MainTarget 83: 16 op, 3006461311.82 ns, 187.9038 ms/op
MainTarget 84: 16 op, 3086185640.46 ns, 192.8866 ms/op
MainTarget 85: 16 op, 3491909172.14 ns, 218.2443 ms/op
MainTarget 86: 16 op, 3256890576.70 ns, 203.5557 ms/op
MainTarget 87: 16 op, 3843333111.96 ns, 240.2083 ms/op
MainTarget 88: 16 op, 4106201398.28 ns, 256.6376 ms/op
MainTarget 89: 16 op, 2898325806.61 ns, 181.1454 ms/op
MainTarget 90: 16 op, 2983530658.33 ns, 186.4707 ms/op
MainTarget 91: 16 op, 2926191798.69 ns, 182.8870 ms/op
MainTarget 92: 16 op, 3584634913.54 ns, 224.0397 ms/op
MainTarget 93: 16 op, 3152651359.64 ns, 197.0407 ms/op
MainTarget 94: 16 op, 3420582979.13 ns, 213.7864 ms/op
MainTarget 95: 16 op, 3513487429.97 ns, 219.5930 ms/op
MainTarget 96: 16 op, 3004037867.08 ns, 187.7524 ms/op
MainTarget 97: 16 op, 3147402373.94 ns, 196.7126 ms/op
MainTarget 98: 16 op, 3334941919.44 ns, 208.4339 ms/op
MainTarget 99: 16 op, 2902031008.50 ns, 181.3769 ms/op
MainTarget 100: 16 op, 3297018692.04 ns, 206.0637 ms/op
Result 1: 16 op, 3276351127.80 ns, 204.7719 ms/op
Result 2: 16 op, 3676617984.45 ns, 229.7886 ms/op
Result 3: 16 op, 3269414968.12 ns, 204.3384 ms/op
Result 4: 16 op, 3021934106.94 ns, 188.8709 ms/op
Result 5: 16 op, 3022635662.19 ns, 188.9147 ms/op
Result 6: 16 op, 3304131387.65 ns, 206.5082 ms/op
Result 7: 16 op, 3061525490.24 ns, 191.3453 ms/op
Result 8: 16 op, 2829643064.14 ns, 176.8527 ms/op
Result 9: 16 op, 3479441412.29 ns, 217.4651 ms/op
Result 10: 16 op, 3297048819.07 ns, 206.0656 ms/op
Result 11: 16 op, 3419245918.66 ns, 213.7029 ms/op
Result 12: 16 op, 3510774729.52 ns, 219.4234 ms/op
Result 13: 16 op, 3510151359.64 ns, 219.3845 ms/op
Result 14: 16 op, 3013516349.50 ns, 188.3448 ms/op
Result 15: 16 op, 3385602057.57 ns, 211.6001 ms/op
Result 16: 16 op, 3250440373.84 ns, 203.1525 ms/op
Result 17: 16 op, 3353277084.14 ns, 209.5798 ms/op
Result 18: 16 op, 3843839898.09 ns, 240.2400 ms/op
Result 19: 16 op, 3365892098.15 ns, 210.3683 ms/op
Result 20: 16 op, 3730196701.12 ns, 233.1373 ms/op
Result 21: 16 op, 3883249855.10 ns, 242.7031 ms/op
Result 22: 16 op, 3524599956.53 ns, 220.2875 ms/op
Result 23: 16 op, 3315631580.85 ns, 207.2270 ms/op
Result 24: 16 op, 2883005940.88 ns, 180.1879 ms/op
Result 25: 16 op, 2912815397.99 ns, 182.0510 ms/op
Result 26: 16 op, 3441889188.08 ns, 215.1181 ms/op
Result 27: 16 op, 3175136084.81 ns, 198.4460 ms/op
Result 28: 16 op, 3421597517.39 ns, 213.8498 ms/op
Result 29: 16 op, 2733257401.95 ns, 170.8286 ms/op
Result 30: 16 op, 2662677441.56 ns, 166.4173 ms/op
Result 31: 16 op, 3072432500.97 ns, 192.0270 ms/op
Result 32: 16 op, 3262999843.03 ns, 203.9375 ms/op
Result 33: 16 op, 3197694527.63 ns, 199.8559 ms/op
Result 34: 16 op, 3342484483.67 ns, 208.9053 ms/op
Result 35: 16 op, 3513276057.77 ns, 219.5798 ms/op
Result 36: 16 op, 3185197244.49 ns, 199.0748 ms/op
Result 37: 16 op, 3175943597.86 ns, 198.4965 ms/op
Result 38: 16 op, 3025001449.00 ns, 189.0626 ms/op
Result 39: 16 op, 3233046090.13 ns, 202.0654 ms/op
Result 40: 16 op, 3170740195.13 ns, 198.1713 ms/op
Result 41: 16 op, 3194739180.83 ns, 199.6712 ms/op
Result 42: 16 op, 3428390286.90 ns, 214.2744 ms/op
Result 43: 16 op, 2956616716.58 ns, 184.7885 ms/op
Result 44: 16 op, 3716766325.35 ns, 232.2979 ms/op
Result 45: 16 op, 3097460273.38 ns, 193.5913 ms/op
Result 46: 16 op, 2886627523.67 ns, 180.4142 ms/op
Result 47: 16 op, 2985384406.39 ns, 186.5865 ms/op
Result 48: 16 op, 3077817329.98 ns, 192.3636 ms/op
Result 49: 16 op, 3182354798.59 ns, 198.8972 ms/op
Result 50: 16 op, 3587742948.22 ns, 224.2339 ms/op
Result 51: 16 op, 3463126328.25 ns, 216.4454 ms/op
Result 52: 16 op, 3578016566.85 ns, 223.6260 ms/op
Result 53: 16 op, 3253869662.87 ns, 203.3669 ms/op
Result 54: 16 op, 3293627680.64 ns, 205.8517 ms/op
Result 55: 16 op, 3153966564.43 ns, 197.1229 ms/op
Result 56: 16 op, 3403995242.47 ns, 212.7497 ms/op
Result 57: 16 op, 2891866245.65 ns, 180.7416 ms/op
Result 58: 16 op, 2830829730.97 ns, 176.9269 ms/op
Result 59: 16 op, 3075858771.25 ns, 192.2412 ms/op
Result 60: 16 op, 3405508235.12 ns, 212.8443 ms/op
Result 61: 16 op, 2883397471.50 ns, 180.2123 ms/op
Result 62: 16 op, 3344388101.33 ns, 209.0243 ms/op
Result 63: 16 op, 3467022012.65 ns, 216.6889 ms/op
Result 64: 16 op, 2992176270.29 ns, 187.0110 ms/op
Result 65: 16 op, 3000386036.51 ns, 187.5241 ms/op
Result 66: 16 op, 3301326676.00 ns, 206.3329 ms/op
Result 67: 16 op, 3342396638.33 ns, 208.8998 ms/op
Result 68: 16 op, 3229188139.97 ns, 201.8243 ms/op
Result 69: 16 op, 3092871486.19 ns, 193.3045 ms/op
Result 70: 16 op, 3386192221.31 ns, 211.6370 ms/op
Result 71: 16 op, 3361272519.80 ns, 210.0795 ms/op
Result 72: 16 op, 3143891820.42 ns, 196.4932 ms/op
Result 73: 16 op, 3054206252.41 ns, 190.8879 ms/op
Result 74: 16 op, 3384095404.27 ns, 211.5060 ms/op
Result 75: 16 op, 3202143849.01 ns, 200.1340 ms/op
Result 76: 16 op, 3469414062.50 ns, 216.8384 ms/op
Result 77: 16 op, 3687211951.80 ns, 230.4507 ms/op
Result 78: 16 op, 3434847070.61 ns, 214.6779 ms/op
Result 79: 16 op, 2942398751.45 ns, 183.8999 ms/op
Result 80: 16 op, 3006460647.70 ns, 187.9038 ms/op
Result 81: 16 op, 3086184976.33 ns, 192.8866 ms/op
Result 82: 16 op, 3491908508.02 ns, 218.2443 ms/op
Result 83: 16 op, 3256889912.58 ns, 203.5556 ms/op
Result 84: 16 op, 3843332447.84 ns, 240.2083 ms/op
Result 85: 16 op, 2898325142.48 ns, 181.1453 ms/op
Result 86: 16 op, 2983529994.20 ns, 186.4706 ms/op
Result 87: 16 op, 2926191134.56 ns, 182.8869 ms/op
Result 88: 16 op, 3584634249.42 ns, 224.0396 ms/op
Result 89: 16 op, 3152650695.52 ns, 197.0407 ms/op
Result 90: 16 op, 3420582315.01 ns, 213.7864 ms/op
Result 91: 16 op, 3513486765.84 ns, 219.5929 ms/op
Result 92: 16 op, 3004037202.96 ns, 187.7523 ms/op
Result 93: 16 op, 3147401709.81 ns, 196.7126 ms/op
Result 94: 16 op, 3334941255.31 ns, 208.4338 ms/op
Result 95: 16 op, 2902030344.38 ns, 181.3769 ms/op
Result 96: 16 op, 3297018027.92 ns, 206.0636 ms/op
GC: 223 100 0 0 1600
Mean = 202.9866 ms, StdErr = 1.6421 ms (0.81%); N = 96, StdDev = 16.0890 ms
Min = 166.4173 ms, Q1 = 189.9752 ms, Median = 203.4612 ms, Q3 = 213.8181 ms, Max = 242.7031 ms
IQR = 23.8429 ms, LowerFence = 154.2109 ms, UpperFence = 249.5824 ms
ConfidenceInterval = [197.4102 ms; 208.5629 ms] (CI 99.9%), Margin = 5.5763 ms (2.75% of Mean)
Skewness = 0.19, Kurtosis = 2.62
// ***** BenchmarkRunner: Finish *****
// * Export *
BenchmarkDotNet.Artifacts\results\LiteDbBench-report.csv
BenchmarkDotNet.Artifacts\results\LiteDbBench-report-github.md
BenchmarkDotNet.Artifacts\results\LiteDbBench-report.html
// * Detailed results *
LiteDbBench.InsertMany: DefaultJob
Runtime = .NET Core 4.6.25302.01, 64bit RyuJIT; GC = Concurrent Workstation
Mean = 202.9866 ms, StdErr = 1.6421 ms (0.81%); N = 96, StdDev = 16.0890 ms
Min = 166.4173 ms, Q1 = 189.9752 ms, Median = 203.4612 ms, Q3 = 213.8181 ms, Max = 242.7031 ms
IQR = 23.8429 ms, LowerFence = 154.2109 ms, UpperFence = 249.5824 ms
ConfidenceInterval = [197.4102 ms; 208.5629 ms] (CI 99.9%), Margin = 5.5763 ms (2.75% of Mean)
Skewness = 0.19, Kurtosis = 2.62
Total time: 00:06:25 (385.53 sec)
// * Summary *
BenchmarkDotNet=v0.10.7, OS=Windows 8.1 (6.3.9600)
Processor=Intel Core i7-4770 CPU 3.40GHz (Haswell), ProcessorCount=8
Frequency=3312640 Hz, Resolution=301.8740 ns, Timer=TSC
dotnet cli version=2.0.0-preview1-005977
[Host] : .NET Core 4.6.25302.01, 64bit RyuJIT
DefaultJob : .NET Core 4.6.25302.01, 64bit RyuJIT
Method | Mean | Error | StdDev |
----------- |---------:|---------:|---------:|
InsertMany | 203.0 ms | 5.576 ms | 16.09 ms |
// * Hints *
Outliers
LiteDbBench.InsertMany: Default -> 4 outliers were removed
// * Legends *
Mean : Arithmetic mean of all measurements
Error : Half of 99.9% confidence interval
StdDev : Standard deviation of all measurements
// ***** BenchmarkRunner: End *****
st probably a DEBUG configuration). Please, build it in RELEASE.
// * Hints *
Outliers
LiteDbBench.InsertMany: Default -> 1 outlier was removed
// * Legends *
Mean : Arithmetic mean of all measurements
Error : Half of 99.9% confidence interval
StdDev : Standard deviation of all measurements
// ***** BenchmarkRunner: End *****
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment