mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-22 20:13:41 +08:00
-
This commit is contained in:
33
Src/Asp.Net/PerformanceTest/Common/PerHelper.cs
Normal file
33
Src/Asp.Net/PerformanceTest/Common/PerHelper.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SqlSugar;
|
||||
|
||||
namespace PerformanceTest.Items
|
||||
{
|
||||
/// <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));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user