Benchmarks.ServiceStack.cs 694 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
using BenchmarkDotNet.Attributes;
using ServiceStack.OrmLite;
using System.Data;

namespace Dapper.Tests.Performance
{
    public class ServiceStackBenchmarks : BenchmarkBase
    {
        private IDbConnection _db;

        [Setup]
        public void Setup()
        {
            BaseSetup();
            var dbFactory = new OrmLiteConnectionFactory(ConnectionString, SqlServerDialect.Provider);
            _db = dbFactory.Open();
        }

        [Benchmark(Description = "ServiceStack.OrmLite: SingleById", OperationsPerInvoke = Iterations)]
        public Post Query()
        {
            Step();
            return _db.SingleById<Post>(i);
        }
    }
}