StopWatch

程序中为了计算使用时间,通常Stopwatchshi'y

Stopwatch watch = Stopwatch.StartNew();

        using (RetailEntities context = new RetailEntities())
        {
          foreach (var entity in customers)
          {
            context.Customers.Add(entity);
          }
          context.SaveChanges();
        }

        watch.Stop();
        Console.WriteLine(string.Format(
          "{0} customers are created, cost {1} milliseconds.", 
          customerCount, watch.ElapsedMilliseconds));
posted @ 2020-01-13 15:13  瘋孑  阅读(112)  评论(0编辑  收藏  举报