From f7ca4a4b0558b457ee2e5811012007d99ad8aa78 Mon Sep 17 00:00:00 2001
From: sunkaixuan <610262374@qq.com>
Date: Mon, 24 Apr 2017 01:31:37 +0800
Subject: [PATCH] -
---
OrmTest/App.config | 6 ----
OrmTest/Models/Student.cs | 2 ++
OrmTest/OrmTest.csproj | 17 ++++++++++-
OrmTest/OrmTest.csproj.user | 2 +-
.../PerformanceTesting/ChloeORMPerformance.cs | 25 ++++++++++++++++
OrmTest/PerformanceTesting/PerformanceBase.cs | 30 +++++++++++++++++++
.../PerformanceTesting/SqlSugarPerformance.cs | 30 +++++++++++++++++++
OrmTest/Program.cs | 12 +++++++-
OrmTest/packages.config | 5 ++++
9 files changed, 120 insertions(+), 9 deletions(-)
delete mode 100644 OrmTest/App.config
create mode 100644 OrmTest/PerformanceTesting/ChloeORMPerformance.cs
create mode 100644 OrmTest/PerformanceTesting/PerformanceBase.cs
create mode 100644 OrmTest/PerformanceTesting/SqlSugarPerformance.cs
create mode 100644 OrmTest/packages.config
diff --git a/OrmTest/App.config b/OrmTest/App.config
deleted file mode 100644
index 88fa4027b..000000000
--- a/OrmTest/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OrmTest/Models/Student.cs b/OrmTest/Models/Student.cs
index 2ead57632..ad087fbe5 100644
--- a/OrmTest/Models/Student.cs
+++ b/OrmTest/Models/Student.cs
@@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using SqlSugar;
using System.Linq.Expressions;
+using Chloe.Entity;
namespace OrmTest.Models
{
@@ -17,6 +18,7 @@ namespace OrmTest.Models
public int SchoolId { get; set; }
public DateTime CreateTime { get; set; }
[SugarColumn(IsIgnore=true)]
+ [NotMappedAttribute]
public int TestId { get; set; }
}
}
diff --git a/OrmTest/OrmTest.csproj b/OrmTest/OrmTest.csproj
index a982a772d..e9c1d6974 100644
--- a/OrmTest/OrmTest.csproj
+++ b/OrmTest/OrmTest.csproj
@@ -33,6 +33,18 @@
4
+
+ ..\packages\Chloe.SqlServer.2.6.0\lib\net40\Chloe.dll
+ True
+
+
+ ..\packages\Chloe.SqlServer.2.6.0\lib\net40\Chloe.SqlServer.dll
+ True
+
+
+ ..\packages\SyntacticSugar.2.4.1\lib\net40\SyntacticSugar.dll
+ True
+
@@ -45,6 +57,9 @@
+
+
+
@@ -59,7 +74,7 @@
-
+
diff --git a/OrmTest/OrmTest.csproj.user b/OrmTest/OrmTest.csproj.user
index 5283ef199..ca1d04b08 100644
--- a/OrmTest/OrmTest.csproj.user
+++ b/OrmTest/OrmTest.csproj.user
@@ -1,6 +1,6 @@
- ShowAllFiles
+ ProjectFiles
\ No newline at end of file
diff --git a/OrmTest/PerformanceTesting/ChloeORMPerformance.cs b/OrmTest/PerformanceTesting/ChloeORMPerformance.cs
new file mode 100644
index 000000000..1d96ea43c
--- /dev/null
+++ b/OrmTest/PerformanceTesting/ChloeORMPerformance.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Chloe;
+using Chloe.SqlServer;
+using OrmTest.Models;
+
+namespace OrmTest.PerformanceTesting
+{
+ public class ChloeORMPerformance: PerformanceBase
+ {
+ public void Select()
+ {
+ MsSqlContext db = new MsSqlContext(Config.ConnectionString);
+ db.Query().Select(it => new ViewModelStudent2 { Name = it.Name, Student = it }).ToList();
+ base.Execute("chloe", () =>
+ {
+ var test = db.Query().Select(it => new ViewModelStudent2 { Name = it.Name, Student = it }).ToList();
+ });
+ db.Dispose();
+ }
+ }
+}
diff --git a/OrmTest/PerformanceTesting/PerformanceBase.cs b/OrmTest/PerformanceTesting/PerformanceBase.cs
new file mode 100644
index 000000000..cba502561
--- /dev/null
+++ b/OrmTest/PerformanceTesting/PerformanceBase.cs
@@ -0,0 +1,30 @@
+using SyntacticSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OrmTest.PerformanceTesting
+{
+ public class PerformanceBase
+ {
+ public int count = 100;
+ public void Execute(string title, Action fun)
+ {
+ PerformanceTest ptef = new PerformanceTest();
+ ptef.SetCount(count);//执行count次
+ ptef.Execute(
+ i =>
+ {
+ fun();
+
+ },
+ res =>
+ {
+ Console.WriteLine(string.Format("Execute {0} time,{1}{2}", count, title, res));
+ });
+
+ }
+ }
+}
diff --git a/OrmTest/PerformanceTesting/SqlSugarPerformance.cs b/OrmTest/PerformanceTesting/SqlSugarPerformance.cs
new file mode 100644
index 000000000..6f902eefa
--- /dev/null
+++ b/OrmTest/PerformanceTesting/SqlSugarPerformance.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using SqlSugar;
+using OrmTest.Models;
+
+namespace OrmTest.PerformanceTesting
+{
+ public class SqlSugarPerformance : PerformanceBase
+ {
+ public void Select()
+ {
+ SqlSugarClient db = new SqlSugarClient(new SystemTablesConfig()
+ {
+ ConnectionString = Config.ConnectionString,
+ DbType = DbType.SqlServer,
+ IsAutoCloseConnection = false
+ });
+ db.IgnoreComumns.Add("TestId", "Student");
+ db.Queryable().Select(it => new ViewModelStudent2 { Name = it.Name, Student = it }).ToList();
+ base.Execute("sqlsuagr", () =>
+ {
+ var test = db.Queryable().Select(it => new ViewModelStudent2 { Name = it.Name, Student = it }).ToList();
+ });
+ db.Close();
+ }
+ }
+}
diff --git a/OrmTest/Program.cs b/OrmTest/Program.cs
index 0e4e4bbc9..ad31cf465 100644
--- a/OrmTest/Program.cs
+++ b/OrmTest/Program.cs
@@ -9,6 +9,8 @@ using SqlSugar;
using OrmTest.Models;
using System.Data.SqlClient;
using OrmTest.UnitTest;
+using OrmTest.PerformanceTesting;
+
namespace OrmTest
{
class Program
@@ -22,7 +24,15 @@ namespace OrmTest
//new Method(eachCount).Init();
//new JoinQuery(eachCount).Init();
//new SingleQuery(eachCount).Init();
- new SelectQuery(eachCount).Init();
+ //new SelectQuery(eachCount).Init();
+
+
+ //Performance Test
+ for (int i = 0; i < 100; i++)
+ {
+
+ new ChloeORMPerformance().Select();
+ }
}
}
}
diff --git a/OrmTest/packages.config b/OrmTest/packages.config
new file mode 100644
index 000000000..d28ea1b98
--- /dev/null
+++ b/OrmTest/packages.config
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file