Пример #1
0
 protected override void ExecuteInternalTest(PerformanceResult result)
 {
     using (var c = new NpgsqlConnection(Connection)) {
         c.Open();
         var cmd = c.CreateCommand();
         cmd.CommandText = Query;
         using (var r = cmd.ExecuteReader()) {
             while (r.Read()) {}
         }
     }
 }
 protected override void ExecuteInternalTest(PerformanceResult result)
 {
     _subtests.AsParallel().ForAll(
         _ =>
             {
                 var task = _.ExecuteAsync();
                 task.Wait();
                 result.Subresults.Add(task.Result);
             }
         );
 }
 /// <summary>
 /// 	јсинхронный вариант вызова
 /// </summary>
 /// <returns> </returns>
 public Task<PerformanceResult> ExecuteAsync()
 {
     return Task.Run(() =>
         {
             var result = new PerformanceResult {Source = this};
             var timecheck = Stopwatch.StartNew();
             try {
                 ExecuteInternalTest(result);
             }
             catch (Exception e) {
                 result.Error = e;
             }
             finally {
                 timecheck.Stop();
                 result.ExecuteTime = timecheck.Elapsed;
             }
             return result;
         });
 }
 protected abstract void ExecuteInternalTest(PerformanceResult result);