Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

233 Commits

Repository files navigation

Actions Status

Comparisons.SQLiteVSDoublets (русская версия)

Comparison of models

Comparison of SQLite and LinksPlatform's Doublets (links) on basic embeded database operations with objects (create list, read list, delete list).

Based on examples from https://github.com/FahaoTang/dotnetcore-examples and https://github.com/Konard/LinksPlatform

SQLite

usingSystem.Linq;usingComparisons.SQLiteVSDoublets.Model;namespaceComparisons.SQLiteVSDoublets.SQLite{publicclassSQLiteTestRun:TestRun{publicSQLiteTestRun(stringdbFilename):base(dbFilename){}publicoverridevoidPrepare(){usingvardbContext=newSQLiteDbContext(DbFilename);dbContext.Database.EnsureCreated();}publicoverridevoidCreateList(){usingvardbContext=newSQLiteDbContext(DbFilename);dbContext.BlogPosts.AddRange(BlogPosts.List);dbContext.SaveChanges();}publicoverridevoidReadList(){usingvardbContext=newSQLiteDbContext(DbFilename);foreach(varblogPostindbContext.BlogPosts){ReadBlogPosts.Add(blogPost);}}publicoverridevoidDeleteList(){usingvardbContext=newSQLiteDbContext(DbFilename);varblogPostsToDelete=dbContext.BlogPosts.ToList();dbContext.BlogPosts.RemoveRange(blogPostsToDelete);dbContext.SaveChanges();}}}

Doublets

usingSystem.IO;usingPlatform.IO;usingComparisons.SQLiteVSDoublets.Model;namespaceComparisons.SQLiteVSDoublets.Doublets{publicclassDoubletsTestRun:TestRun{publicstringDbIndexFilename{get;}publicDoubletsTestRun(stringdbFilename):base(dbFilename)=>DbIndexFilename=$"{Path.GetFileNameWithoutExtension(dbFilename)}.links.index";publicoverridevoidPrepare(){usingvardbContext=newDoubletsDbContext(DbFilename,DbIndexFilename);}publicoverridevoidCreateList(){usingvardbContext=newDoubletsDbContext(DbFilename,DbIndexFilename);foreach(varblogPostinBlogPosts.List){dbContext.SaveBlogPost(blogPost);}}publicoverridevoidReadList(){usingvardbContext=newDoubletsDbContext(DbFilename,DbIndexFilename);foreach(varblogPostindbContext.BlogPosts){ReadBlogPosts.Add(blogPost);}}publicoverridevoidDeleteList(){usingvardbContext=newDoubletsDbContext(DbFilename,DbIndexFilename);varblogPostsToDelete=dbContext.BlogPosts;foreach(varblogPostinblogPostsToDelete){dbContext.Delete((uint)blogPost.Id);}}protectedoverridevoidDeleteDatabase(){File.Delete(DbFilename);File.Delete(DbIndexFilename);}protectedoverridelongGetDatabaseSizeInBytes()=>FileHelpers.GetSize(DbFilename)+FileHelpers.GetSize(DbIndexFilename);}}

Performance

Image with result of performance comparison between SQLite and Doublets.

Disk usage

Image with result of disk usage comparison between SQLite and Doublets.

RAM usage

Image with result of RAM usage comparison between SQLite and Doublets.

Source data

BenchmarkDotNet=v0.12.0, OS=Windows 10.0.18362
Intel Core i7-6700K CPU 4.00GHz (Skylake), 1 CPU, 8 logical and 4 physical cores
.NET Core SDK=3.0.100
[Host] : .NET Core 3.0.0 (CoreCLR 4.700.19.46205, CoreFX 4.700.19.46214), X64 RyuJIT
Job-AYEMIX : .NET Core 3.0.0 (CoreCLR 4.700.19.46205, CoreFX 4.700.19.46214), X64 RyuJIT
InvocationCount=1 IterationCount=1 UnrollFactor=1 WarmupCount=2 
MethodNMeanErrorGen 0Gen 1Gen 2AllocatedSizeAfterCreation
SQLite1000719.1 msNA5000.0000--30.67 MB925696
Doublets1000145.0 msNA34000.00001000.0000-139.37 MB767616
SQLite100002,770.3 msNA64000.000019000.0000-315.71 MB9056256
Doublets100001,003.8 msNA304000.000031000.0000-1220.55 MB6528256
SQLite10000035,853.8 msNA680000.0000151000.0000-3234.09 MB90890240
Doublets10000013,083.4 msNA3088000.0000328000.0000-12356.33 MB64192256

Conclusion

In this particular comparison, Doublets are faster and use less memory on disk, but this comes with the cost of additional use of RAM (Sqlite uses it less).

About

Comparison of SQLite and LinksPlatform's Doublets (links) on basic embeded database operations with objects (create list, read list, delete list).

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages