File tree Expand file tree Collapse file tree 2 files changed +72
-0
lines changed Expand file tree Collapse file tree 2 files changed +72
-0
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . Collections ;
3
+ using System . Diagnostics ;
3
4
using System . Linq ;
4
5
using NHibernate . AdoNet ;
5
6
using NHibernate . Cfg ;
@@ -61,6 +62,41 @@ public void BatchSizeTest()
61
62
Cleanup ( ) ;
62
63
}
63
64
65
+ // Demonstrates a 50% performance gain with SQL-Server, around 40% for PostgreSQL,
66
+ // around 15% for MySql, but around 200% performance loss for SQLite.
67
+ // (Tested with databases on same machine for all cases.)
68
+ [ Theory , Explicit ( "This is a performance test, to be checked manually." ) ]
69
+ public void MassivePerformanceTest ( bool batched )
70
+ {
71
+ if ( batched )
72
+ {
73
+ // Bring down batch size to a reasonnable value, otherwise performances are worsen.
74
+ cfg . SetProperty ( Environment . BatchSize , "50" ) ;
75
+ }
76
+ else
77
+ {
78
+ cfg . SetProperty ( Environment . BatchStrategy , typeof ( NonBatchingBatcherFactory ) . AssemblyQualifiedName ) ;
79
+ cfg . Properties . Remove ( Environment . BatchSize ) ;
80
+ }
81
+ RebuildSessionFactory ( ) ;
82
+
83
+ try
84
+ {
85
+ // Warm up
86
+ MassiveInsertUpdateDeleteTest ( ) ;
87
+
88
+ var chrono = new Stopwatch ( ) ;
89
+ chrono . Start ( ) ;
90
+ MassiveInsertUpdateDeleteTest ( ) ;
91
+ Console . WriteLine ( $ "Elapsed time: { chrono . Elapsed } ") ;
92
+ }
93
+ finally
94
+ {
95
+ Configure ( cfg ) ;
96
+ RebuildSessionFactory ( ) ;
97
+ }
98
+ }
99
+
64
100
private void BatchInsert ( int totalRecords )
65
101
{
66
102
Sfi . Statistics . Clear ( ) ;
Original file line number Diff line number Diff line change 10
10
11
11
using System ;
12
12
using System . Collections ;
13
+ using System . Diagnostics ;
13
14
using System . Linq ;
14
15
using NHibernate . AdoNet ;
15
16
using NHibernate . Cfg ;
@@ -74,6 +75,41 @@ public async Task BatchSizeTestAsync()
74
75
await ( CleanupAsync ( ) ) ;
75
76
}
76
77
78
+ // Demonstrates a 50% performance gain with SQL-Server, around 40% for PostgreSQL,
79
+ // around 15% for MySql, but around 200% performance loss for SQLite.
80
+ // (Tested with databases on same machine for all cases.)
81
+ [ Theory , Explicit ( "This is a performance test, to be checked manually." ) ]
82
+ public async Task MassivePerformanceTestAsync ( bool batched )
83
+ {
84
+ if ( batched )
85
+ {
86
+ // Bring down batch size to a reasonnable value, otherwise performances are worsen.
87
+ cfg . SetProperty ( Environment . BatchSize , "50" ) ;
88
+ }
89
+ else
90
+ {
91
+ cfg . SetProperty ( Environment . BatchStrategy , typeof ( NonBatchingBatcherFactory ) . AssemblyQualifiedName ) ;
92
+ cfg . Properties . Remove ( Environment . BatchSize ) ;
93
+ }
94
+ RebuildSessionFactory ( ) ;
95
+
96
+ try
97
+ {
98
+ // Warm up
99
+ await ( MassiveInsertUpdateDeleteTestAsync ( ) ) ;
100
+
101
+ var chrono = new Stopwatch ( ) ;
102
+ chrono . Start ( ) ;
103
+ await ( MassiveInsertUpdateDeleteTestAsync ( ) ) ;
104
+ Console . WriteLine ( $ "Elapsed time: { chrono . Elapsed } ") ;
105
+ }
106
+ finally
107
+ {
108
+ Configure ( cfg ) ;
109
+ RebuildSessionFactory ( ) ;
110
+ }
111
+ }
112
+
77
113
private async Task BatchInsertAsync ( int totalRecords , CancellationToken cancellationToken = default ( CancellationToken ) )
78
114
{
79
115
Sfi . Statistics . Clear ( ) ;
You can’t perform that action at this time.
0 commit comments