Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
Ftt_Common
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Ftt_Common
Commits
96ed1fb0
Commit
96ed1fb0
authored
Nov 30, 2021
by
罗显健
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试项目调整:增加类 DboPerformanceTest
parent
8b1cccb7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
43 deletions
+98
-43
DboPerformance.cs
test/Cases/DboPerformance.cs
+88
-0
FrmDbo.cs
test/FrmDbo.cs
+6
-43
test.csproj
test/test.csproj
+4
-0
No files found.
test/Cases/DboPerformance.cs
0 → 100644
View file @
96ed1fb0
using
System
;
using
System.Collections.Generic
;
using
System.Data
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
test.Extension
;
using
test.Tester
;
namespace
test.Cases
{
/// <summary>
/// Dbo性能测试
/// </summary>
public
class
DboPerformanceTest
{
Dictionary
<
string
,
double
>
dicTimes
=
new
Dictionary
<
string
,
double
>();
public
void
RunDapper
()
{
Test1
(
new
TDapper
());
}
public
void
RunFluentData
()
{
Test1
(
new
TFluentData
());
}
public
void
RunSqlHelper
()
{
Test1
(
new
TSqlHelper
());
}
public
void
Test1
(
ITester
tester
)
{
dicTimes
.
Clear
();
try
{
TimeWatch
timeWatch
=
TimeWatch
.
Start
();
var
sql
=
"Update OrderStyleBOM Set SubmitDate = @SubmitDate,LastModifiedMemo = @LastModifiedMemo,Remark = @Remark Where UID = @UID"
;
Dictionary
<
string
,
object
>
data
=
new
Dictionary
<
string
,
object
>()
{
{
"SubmitDate"
,
DateTime
.
Now
},
{
"LastModifiedMemo"
,
"更新测试"
},
{
"UID"
,
Guid
.
Parse
(
"F25701F7-D877-46CB-986D-991090168B97"
)
},
{
"Remark"
,
null
}
};
tester
.
Execute
(
sql
,
data
);
ShowTestTime
(
"更新1条记录"
,
timeWatch
);
#
region
Select
5000
DataTable
dtBom
=
tester
.
GetDataTable
(
"Select top(5000) * From OrderStyleBOM"
);
ShowTestTime
(
"查询5000条记录"
,
timeWatch
);
#
endregion
var
dtQuery
=
tester
.
GetDataTable
(
"Select top(100) * From OrderStyleBOM order by ID"
);
#
region
Update
100
var
upCommand
=
dtBom
.
GetUpdateCommand
(
"OrderStyleBOM"
,
"UID"
);
tester
.
Update
(
upCommand
,
dtQuery
);
ShowTestTime
(
"更新100条记录"
,
timeWatch
);
#
endregion
#
region
Insert
100
foreach
(
DataRow
row
in
dtQuery
.
Rows
)
row
[
"UID"
]
=
Guid
.
NewGuid
();
//
tester
.
Insert
(
dtQuery
.
GetInsertCommand
(
"OrderStyleBOM"
),
dtQuery
);
ShowTestTime
(
"插入100条记录"
,
timeWatch
);
#
endregion
}
catch
{
throw
;
}
}
private
void
ShowTestTime
(
string
text
,
TimeWatch
timeWatch
)
{
dicTimes
.
Add
(
text
,
timeWatch
.
TimeSpan
.
TotalMilliseconds
);
timeWatch
.
ShowLog
(
text
,
true
);
}
public
Dictionary
<
string
,
double
>
Result
=>
dicTimes
;
}
}
test/FrmDbo.cs
View file @
96ed1fb0
...
...
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using
System.Data
;
using
System.Text
;
using
System.Windows.Forms
;
using
test.Cases
;
using
test.Extension
;
using
test.Tester
;
...
...
@@ -76,58 +77,20 @@ namespace test
button
.
Enabled
=
false
;
Test1
(
tester
);
button
.
Enabled
=
true
;
}
private
void
Test1
(
ITester
tester
)
{
dicTimes
.
Clear
();
TimeWatch
timeWatch
=
TimeWatch
.
Start
();
var
sql
=
"Update OrderStyleBOM Set SubmitDate = @SubmitDate,LastModifiedMemo = @LastModifiedMemo,Remark = @Remark Where UID = @UID"
;
Dictionary
<
string
,
object
>
data
=
new
Dictionary
<
string
,
object
>()
{
{
"SubmitDate"
,
DateTime
.
Now
},
{
"LastModifiedMemo"
,
"更新测试"
},
{
"UID"
,
Guid
.
Parse
(
"F25701F7-D877-46CB-986D-991090168B97"
)
},
{
"Remark"
,
null
}
};
tester
.
Execute
(
sql
,
data
);
ShowTestTime
(
"更新1条记录"
,
timeWatch
);
#
region
Select
5000
DataTable
dtBom
=
tester
.
GetDataTable
(
"Select top(5000) * From OrderStyleBOM"
);
ShowTestTime
(
"查询5000条记录"
,
timeWatch
);
#
endregion
var
dtQuery
=
tester
.
GetDataTable
(
"Select top(100) * From OrderStyleBOM order by ID"
);
#
region
Update
100
var
upCommand
=
dtBom
.
GetUpdateCommand
(
"OrderStyleBOM"
,
"UID"
);
tester
.
Update
(
upCommand
,
dtQuery
);
ShowTestTime
(
"更新100条记录"
,
timeWatch
);
#
endregion
#
region
Insert
100
foreach
(
DataRow
row
in
dtQuery
.
Rows
)
row
[
"UID"
]
=
Guid
.
NewGuid
();
//
tester
.
Insert
(
dtQuery
.
GetInsertCommand
(
"OrderStyleBOM"
),
dtQuery
);
ShowTestTime
(
"插入100条记录"
,
timeWatch
);
#
endregion
ShowTester
(
tester
.
GetType
().
Name
);
DboPerformanceTest
performanceTest
=
new
DboPerformanceTest
();
performanceTest
.
Test1
(
tester
);
var
dicTimes
=
performanceTest
.
Result
;
ShowTester
(
tester
.
GetType
().
Name
,
dicTimes
);
}
Dictionary
<
string
,
double
>
dicTimes
=
new
Dictionary
<
string
,
double
>();
private
void
ShowTestTime
(
string
text
,
TimeWatch
timeWatch
)
{
dicTimes
.
Add
(
text
,
timeWatch
.
TimeSpan
.
TotalMilliseconds
);
timeWatch
.
ShowLog
(
text
,
true
);
}
private
void
ShowTester
(
string
testerName
)
private
void
ShowTester
(
string
testerName
,
Dictionary
<
string
,
double
>
dicTimes
)
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
AppendLine
(
$"
{
testerName
}
测试完成:"
);
...
...
test/test.csproj
View file @
96ed1fb0
...
...
@@ -33,6 +33,9 @@
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject
/>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"Dapper, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Dapper.2.0.78\lib\net461\Dapper.dll
</HintPath>
...
...
@@ -55,6 +58,7 @@
<Reference
Include=
"System.Xml"
/>
</ItemGroup>
<ItemGroup>
<Compile
Include=
"Cases\DboPerformance.cs"
/>
<Compile
Include=
"DBO\DbFluentData.cs"
/>
<Compile
Include=
"DBO\DbSqlHelper.cs"
/>
<Compile
Include=
"Extension\DataTableExtension.cs"
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment