@@ -57,12 +57,6 @@ function Bench() {
5757 const config = conf . baseConfig ;
5858 config . charsetNumber = 224 ;
5959 config . trace = false ;
60- //To benchmark same pool implementation than mysql/mysql2
61- //standard implementation rollback/reset connection after use
62- config . noControlAfterUse = true ;
63-
64- // default is true, but better to compare the same level of implementation
65- config . checkDuplicate = false ;
6660
6761 const poolConfig = Object . assign ( { connectionLimit : 4 } , config ) ;
6862 // config.debug = true;
@@ -80,7 +74,7 @@ function Bench() {
8074 this . driverLen ++ ;
8175 connList [ 'PROMISE_MYSQL' ] = { desc : 'promise-mysql' , promise : true } ;
8276 promiseMysql
83- . createConnection ( config )
77+ . createConnection ( Object . assign ( { } , config ) )
8478 . then ( ( conn ) => {
8579 promiseMysql
8680 . createPool ( poolConfig )
@@ -101,7 +95,7 @@ function Bench() {
10195 if ( mysql ) {
10296 this . driverLen ++ ;
10397 connList [ 'MYSQL' ] = { desc : 'mysql' , promise : false } ;
104- const conn = mysql . createConnection ( config ) ;
98+ const conn = mysql . createConnection ( Object . assign ( { } , config ) ) ;
10599 conn . connect ( ( err ) => {
106100 connList [ 'MYSQL' ] . drv = conn ;
107101 conn . on ( 'error' , ( err ) => console . log ( 'driver mysql error :' + err ) ) ;
@@ -112,7 +106,7 @@ function Bench() {
112106 if ( mysql2 ) {
113107 this . driverLen ++ ;
114108 connList [ 'MYSQL2' ] = { desc : 'mysql2' , promise : false } ;
115- const conn = mysql2 . createConnection ( config ) ;
109+ const conn = mysql2 . createConnection ( Object . assign ( { } , config ) ) ;
116110 conn . connect ( ( ) => {
117111 connList [ 'MYSQL2' ] . drv = conn ;
118112 conn . on ( 'error' , ( err ) => console . log ( 'driver mysql2 error :' + err ) ) ;
@@ -124,7 +118,7 @@ function Bench() {
124118 this . driverLen ++ ;
125119 connList [ 'PROMISE_MYSQL2' ] = { desc : 'promise mysql2' , promise : true } ;
126120 promiseMysql2
127- . createConnection ( config )
121+ . createConnection ( Object . assign ( { } , config ) )
128122 . then ( ( conn ) => {
129123 connList [ 'PROMISE_MYSQL2' ] . drv = conn ;
130124 conn . on ( 'error' , ( err ) => console . log ( 'driver mysql2 promise error :' + err ) ) ;
@@ -136,7 +130,12 @@ function Bench() {
136130 } ) ;
137131 }
138132
139- const mariaConn = callbackMariadb . createConnection ( config ) ;
133+ //To benchmark same things with mysql/mysql2, 2 options are changed compared to default values:
134+ // * checkDuplicate = false => normally, driver check there isn't some missing field if same identifier
135+ // * noControlAfterUse = true => pool normally reset connection after use.
136+ const mariaConn = callbackMariadb . createConnection (
137+ Object . assign ( { checkDuplicate : false } , config )
138+ ) ;
140139 connList [ 'MARIADB' ] = { desc : 'mariadb' , promise : true } ;
141140 mariaConn . connect ( ( ) => {
142141 connList [ 'MARIADB' ] . drv = mariaConn ;
@@ -146,11 +145,13 @@ function Bench() {
146145
147146 connList [ 'PROMISE_MARIADB' ] = { desc : 'promise mariadb' , promise : false } ;
148147 mariadb
149- . createConnection ( config )
148+ . createConnection ( Object . assign ( { checkDuplicate : false } , config ) )
150149 . then ( ( conn ) => {
151150 connList [ 'PROMISE_MARIADB' ] . drv = conn ;
152151 conn . on ( 'error' , ( err ) => console . log ( 'driver mariadb promise error :' + err ) ) ;
153- connList [ 'PROMISE_MARIADB' ] . pool = mariadb . createPool ( poolConfig ) ;
152+ connList [ 'PROMISE_MARIADB' ] . pool = mariadb . createPool (
153+ Object . assign ( { noControlAfterUse : true , checkDuplicate : false } , poolConfig )
154+ ) ;
154155 dbReady ( 'promise-mariadb' , this . driverLen ) ;
155156 } )
156157 . catch ( ( err ) => {
@@ -170,7 +171,7 @@ function Bench() {
170171 this . driverLen ++ ;
171172 connList [ 'PROMISE_MARIASQL' ] = { desc : 'promise mariasql' , promise : false } ;
172173 promiseMariasql
173- . createConnection ( config )
174+ . createConnection ( configC )
174175 . then ( ( conn ) => {
175176 connList [ 'PROMISE_MARIASQL' ] . drv = conn ;
176177 dbReady ( 'promise-mariasql' , this . driverLen ) ;
@@ -183,7 +184,7 @@ function Bench() {
183184 if ( mariasql ) {
184185 this . driverLen ++ ;
185186 connList [ 'MARIASQL' ] = { desc : 'mariasql' , drv : conn , promise : true } ;
186- const conn = mariasql . createConnection ( config ) ;
187+ const conn = mariasql . createConnection ( configC ) ;
187188 conn . connect ( ( err ) => {
188189 connList [ 'MARIASQL' ] . drv = conn ;
189190 dbReady ( 'mariasql' , this . driverLen ) ;
0 commit comments