Performance Comparison: Inverted software’s DataBlock vs. ServiceStack’s OrmLite

ServiceStack is a leading commercial framework for .NET development.

It includes multiple components designed to help development of modern APIs and web applications.

One such component is its OrmLite. A fast, simple typed ORM for .NET.

OrmLite’s goal is to provide a convenient, DRY, config-free, RDBMS-agnostic typed wrapper that retains a high affinity with SQL, exposing intuitive APIs that generate predictable SQL and maps cleanly to (DTO-friendly) disconnected POCO’s.

This approach makes easier to reason-about your data access making it obvious what SQL is getting executed at what time, whilst mitigating unexpected behavior, implicit N+1 queries and leaky data access prevalent in Heavy ORMs.

We decided to put OrmLite to the test against our own open source Inverted software’s DataBlock.

We wanted to see which framework performs better.

The test is simple: Get a list of objects from the database.

Here is the code we used with OrmLite:

public List<MyObject> GetListOfObjectsWithOrmLite()
            return Db.SqlList<MyObject>("GetListOfObjects", cmd =>
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.AddParam("ID", 1);
                cmd.AddParam("FromDate", DateTime.Now.AddDays(-14));
                cmd.AddParam("ToDate", DateTime.Now.AddDays(14));

And the code we used with Inverted Software’s data Block:

public List<MyObject> GetListOfObjectsWithDataBlock()
           return CRUDHelper.GetObjectList<MyObject>(() => new MyObject(),
               new SqlParameter[]{
                   new SqlParameter("ID", SqlDbType.Int){ Value = 1},
                   new SqlParameter("FromDate", SqlDbType.DateTime){ Value = DateTime.Now.AddDays(-14)},
                   new SqlParameter("ToDate", SqlDbType.DateTime){ Value = DateTime.Now.AddDays(14)},

We allowed one call to warm up both frameworks and then executed the same query 5,000 times in each one.

Here is the code we used:

public object Get(Request request)
           // ServiceStack warm up.
           var tmp = repository.GetListOfObjectsWithOrmLite();
           // Start the clock.
           Stopwatch stopWatch = new Stopwatch();
           for (int i = 0; i < 5000; i++)
               tmp = repository.GetListOfObjectsWithOrmLite();
           TimeSpan ts = stopWatch.Elapsed;
           string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
               ts.Hours, ts.Minutes, ts.Seconds,
               ts.Milliseconds / 10);
           Response.Write("ServiceStack RunTime " + elapsedTime + Environment.NewLine);
           // Inverted Software warm up.
           tmp = repository.GetListOfObjectsWithDataBlock();
           // start the clock
           for (int i = 0; i < 5000; i++)
               tmp = repository.GetListOfObjectsWithDataBlock();
           ts = stopWatch.Elapsed;
           elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
               ts.Hours, ts.Minutes, ts.Seconds,
               ts.Milliseconds / 10);
           Response.Write("InvertedSoftware RunTime " + elapsedTime);
           return tmp;

We should note that the test took place inside an API service that is built on top of the ServiceStack framework while ServiceStack’s OrmLite is registered using dependency injection according to its official documentation.

The results were as follow:

ServiceStack: Run Time 00:00:07.62
Inverted Software: Run Time 00:00:05.28

As you see, our framework performed 20% faster!

Want to know how we can help fine tune your applications?

Contact us today:

Phone: 818.262.8552

Interested in downloading Inverted Software’s DataBlock?

Try the Nuget package here.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s