SqlSugar/Src/Asp.Net/PerformanceTest/Common/PerHelper.cs

34 lines
873 B
C#
Raw Normal View History

2017-09-21 13:52:52 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;
2017-09-21 14:24:53 +08:00
namespace PerformanceTest
2017-09-21 13:52:52 +08:00
{
/// <summary>
/// 性能测试类,用于循环执行代码并统计时间
/// </summary>
public class PerHelper
{
public static void Execute(int count, string title, Action fun)
{
SyntacticSugar.PerformanceTest ptef = new SyntacticSugar.PerformanceTest();
ptef.SetCount(count);//执行count次
ptef.Execute(
i =>
{
fun();
},
res =>
{
Console.WriteLine(string.Format("执行{0}次,{1}{2}", count, title, res));
});
}
}
}