We mentioned in the MicroLite 5.0 Released post that there has been some work internally in MicroLite to improve performance and reduce memory usage. We’ll dive into the details in future posts, but for now here’s a brief summary of some of the results.
The calls are based upon a single instance of an entity, with the action performed 100 times inside an individual transaction each time.
The INSERT, UPDATE and DELETE calls were performed against an instance (e.g.)
session.Insert(entity); session.Update(entity); session.Delete(entity);
The SELECT call was performed against the identifier of an instance (e.g.)
var entity = session.Single<Entity>(id);
The test also included performing a SELECT query which resulted in 100 results using Fetch and Paged (e.g.):
var entities = session.Fetch<Entity>( new SqlQuery("SELECT * FROM Entity WHERE Id <= @p0", 100)); var paged = session.Paged<Entity>( new SqlQuery("SELECT * FROM Entity"), PagingOptions.ForPage(1, 100));
The tests were run on a virtual machine using a local SQLite database and the results are as follows:
|Activity||MicroLite 4.0||MicroLite 5.0||Improvement|
|INSERT||20.79 ms||15.70 ms||24.48% faster|
|UPDATE||21.26 ms||16.19 ms||23.85% faster|
|DELETE||14.13 ms||11.15 ms||21.09% faster|
|SELECT (Single)||13.36 ms||7.95 ms||40.49% faster|
|SELECT (Fetch)||4.07 ms||2.42 ms||40.54% faster|
|SELECT (Paged)||4.27 ms||2.28 ms||46.60% faster|
The following are based upon the above tests run in a profiler.
|Version||CLR Heap Used||CLR Heap Allocated||Process Mem Used||Process VM Size||GC Count|
|MicroLite 4.0||565 KB||3.8 MB||72 MB||60 MB||28|
|MicroLite 5.0||395 KB||3.6 MB||69 MB||57 MB||17|