mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-30 04:45:54 +08:00
-
This commit is contained in:
parent
b7e919999c
commit
b82ebd4608
@ -5,7 +5,7 @@ using System.Text;
|
||||
|
||||
namespace PerformanceTest.Items
|
||||
{
|
||||
public class PubConst
|
||||
public class Config
|
||||
{
|
||||
public static string connectionString = "server=.;uid=sa;pwd=sasa;database=SqlSugarTest";
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Data.SqlClient;
|
||||
using SqlSugar;
|
||||
using Dapper;
|
||||
using Dapper.Contrib;
|
||||
using Dapper.Contrib.Extensions;
|
||||
namespace PerformanceTest.Items
|
||||
{
|
||||
public class WarmUp
|
||||
{
|
||||
public WarmUp()
|
||||
{
|
||||
Console.WriteLine("开启预热");
|
||||
|
||||
Console.WriteLine("预热完毕");
|
||||
Console.WriteLine("----------------比赛开始-------------------");
|
||||
}
|
||||
}
|
||||
}
|
@ -55,10 +55,9 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Items\PerHelper.cs" />
|
||||
<Compile Include="Items\PubConst.cs" />
|
||||
<Compile Include="Items\SelectBigData.cs" />
|
||||
<Compile Include="Items\WarmUp.cs" />
|
||||
<Compile Include="Common\PerHelper.cs" />
|
||||
<Compile Include="Config.cs" />
|
||||
<Compile Include="TestItems\TestGetAll.cs" />
|
||||
<Compile Include="Models\TestEntity.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
@ -15,9 +15,7 @@ namespace PerformanceTest
|
||||
/// <param name="args"></param>
|
||||
static void Main(string[] args)
|
||||
{
|
||||
WarmUp wu = new WarmUp();//预热处理
|
||||
|
||||
new SelectBigData().Init();
|
||||
new TestGetAll().Init();
|
||||
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ using Dapper.Contrib.Extensions;
|
||||
|
||||
namespace PerformanceTest.Items
|
||||
{
|
||||
public class SelectBigData
|
||||
public class TestGetAll
|
||||
{
|
||||
/// <summary>
|
||||
/// 测试一次读取100万条数据的速度
|
||||
@ -17,12 +17,16 @@ namespace PerformanceTest.Items
|
||||
public void Init()
|
||||
{
|
||||
Console.WriteLine("测试一次读取100万条数据的速度");
|
||||
var eachCount = 1000;
|
||||
var eachCount = 1;
|
||||
|
||||
Console.WriteLine("开启预热");
|
||||
Dapper(1);
|
||||
SqlSugar(1);
|
||||
Console.WriteLine("预热完毕");
|
||||
|
||||
/*******************车轮战是性能评估最准确的一种方式***********************/
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
|
||||
//dapper
|
||||
Dapper(eachCount);
|
||||
|
||||
@ -39,10 +43,9 @@ namespace PerformanceTest.Items
|
||||
|
||||
PerHelper.Execute(eachCount, "SqlSugar", () =>
|
||||
{
|
||||
using (SqlSugarClient conn = new SqlSugarClient(new ConnectionConfig() { InitKeyType=InitKeyType.SystemTable, ConnectionString= PubConst.connectionString, DbType=DbType.SqlServer }))
|
||||
using (SqlSugarClient conn = new SqlSugarClient(new ConnectionConfig() { InitKeyType=InitKeyType.SystemTable, ConnectionString= Config.connectionString, DbType=DbType.SqlServer }))
|
||||
{
|
||||
// var list = conn.Ado.SqlQuery<Test>("select * from test where id=1");
|
||||
var list2 = conn.Queryable<Test>().InSingle(1);
|
||||
var list2 = conn.Queryable<Test>().ToList();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -55,9 +58,9 @@ namespace PerformanceTest.Items
|
||||
//正试比拼
|
||||
PerHelper.Execute(eachCount, "Dapper", () =>
|
||||
{
|
||||
using (SqlConnection conn = new SqlConnection(PubConst.connectionString))
|
||||
using (SqlConnection conn = new SqlConnection(Config.connectionString))
|
||||
{
|
||||
var list = conn.Get<Test>(1);
|
||||
var list = conn.GetAll<Test>();
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user