private void GetItemAsObjectTest(IOrmExecuter executer)
        {
            if (executer is IOrmWithCacheExecuter ormWithCacheExecuter)
            {
                ormWithCacheExecuter.ClearCache();
            }

            double executionTime     = 0;
            double firstItemExecTime = 0;
            bool   onlyFirst         = true;

            foreach (var id in _idList)
            {
                Stopwatch stopwatch = Stopwatch.StartNew();
                var       result    = executer.GetItemAsObject(id);;
                stopwatch.Stop();

                if (result is null)
                {
                    return;
                }

                executionTime += GetNanoSeconds(stopwatch);

                if (onlyFirst)
                {
                    firstItemExecTime = executionTime;
                    onlyFirst         = false;
                }
            }
            Results.Add(CreateResult(executer, executionTime, nameof(GetItemAsObjectTest), firstItemExecTime));
        }
        private void WarmUp(IOrmExecuter executer)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            executer.GetItemAsObject(1);
            executer.GetItemAsDynamic(1);
            stopwatch.Stop();

            ResultsWarmUp.Add(CreateResult(executer, GetNanoSeconds(stopwatch), "WarmUp"));
        }
 private static BenchmarkResult CreateResult(IOrmExecuter executer, double elapsedMilliseconds, string testName, double?firstItemExecTime = null)
 {
     return(new BenchmarkResult
     {
         Name = executer.Name,
         DatabaseType = executer.DatabaseProvider.ToString(),
         ExecTime = elapsedMilliseconds,
         FirstItemExecTime = firstItemExecTime,
         TestName = testName
     });
 }
        private void GetAllItemsAsObjectTest(IOrmExecuter executer)
        {
            if (executer is IOrmWithCacheExecuter ormWithCacheExecuter)
            {
                ormWithCacheExecuter.ClearCache();
            }

            Stopwatch stopwatch = Stopwatch.StartNew();
            var       result    = executer.GetAllItemsAsObject();

            stopwatch.Stop();

            if (result is null)
            {
                return;
            }

            if (!result.Any())
            {
                return;
            }

            ResultsForAllItems.Add(CreateResult(executer, GetNanoSeconds(stopwatch), nameof(GetAllItemsAsObjectTest)));
        }
Exemple #5
0
 public void RegisterOrmExecuter(IOrmExecuter executer)
 {
     executers.Add(executer);
 }