Added CRUD tests
This commit is contained in:
parent
c505d522f9
commit
a37ecd700e
79
test/Performance/benchmark/pdo_sqlsrv/PDOCRUDBench.php
Normal file
79
test/Performance/benchmark/pdo_sqlsrv/PDOCRUDBench.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
use PDOSqlsrvPerfTest\PDOSqlsrvUtil;
|
||||
include_once __DIR__ . "/../../lib/CRUDBaseBenchmark.php";
|
||||
/**
|
||||
* @BeforeMethods({"connect", "setTableName", "createTable", "generateInsertValues", "generateUpdateValues", "generateUpdateParams"})
|
||||
* @AfterMethods({ "dropTable", "disconnect"})
|
||||
*/
|
||||
class PDOSqlsrvCRUDBench extends CRUDBaseBenchmark
|
||||
{
|
||||
|
||||
private $conn;
|
||||
private $tableName;
|
||||
private $insertValues;
|
||||
private $updateValues;
|
||||
private $updateParams;
|
||||
|
||||
public function setTableName()
|
||||
{
|
||||
$this->tableName = "datatypes_".rand();
|
||||
}
|
||||
|
||||
public function connect()
|
||||
{
|
||||
$this->conn = PDOSqlsrvUtil::connect();
|
||||
}
|
||||
|
||||
public function createTable()
|
||||
{
|
||||
PDOSqlsrvUtil::createCRUDTable( $this->conn, $this->tableName );
|
||||
}
|
||||
|
||||
public function generateInsertValues()
|
||||
{
|
||||
$this->insertValues = PDOSqlsrvUtil::generateInsertValues();
|
||||
}
|
||||
|
||||
public function generateUpdateValues()
|
||||
{
|
||||
$this->updateValues = PDOSqlsrvUtil::generateUpdateValues();
|
||||
}
|
||||
|
||||
public function generateUpdateParams()
|
||||
{
|
||||
$this->updateParams = PDOSqlsrvUtil::generateUpdateParams();
|
||||
}
|
||||
/**
|
||||
* Each iteration does the following $loopsPerCRUDIter times:
|
||||
* (i) insert a row into the table with insertWithPrepare
|
||||
* (ii) fetch the row with fetchWithPrepare
|
||||
* (iii) update the row's contents with updateWithPrepare
|
||||
* (iv) delete the row with delete
|
||||
* Every insertion calls prepare, bindParam and execute APIs.
|
||||
* Every fetch calls prepare, execute and fetch APIs.
|
||||
* Every update calls prepare, bindParam and execute APIs.
|
||||
* Every delete calls prepare and execute APIs.
|
||||
*/
|
||||
public function benchCRUDWithPrepare()
|
||||
{
|
||||
for( $i=0; $i<PDOSqlsrvUtil::$loopsPerCRUDIter; $i++ )
|
||||
{
|
||||
PDOSqlsrvUtil::insertWithPrepare( $this->conn, $this->tableName, $this->insertValues );
|
||||
PDOSqlsrvUtil::fetchWithPrepare( $this->conn, $this->tableName );
|
||||
$stmt = PDOSqlsrvUtil::updateWithPrepare( $this->conn, $this->tableName, $this->updateValues, $this->updateParams );
|
||||
PDOSqlsrvUtil::deleteWithPrepare( $this->conn, $this->tableName );
|
||||
}
|
||||
}
|
||||
|
||||
public function dropTable()
|
||||
{
|
||||
PDOSqlsrvUtil::dropTable( $this->conn, $this->tableName );
|
||||
}
|
||||
|
||||
public function disconnect()
|
||||
{
|
||||
PDOSqlsrvUtil::disconnect( $this->conn );
|
||||
}
|
||||
|
||||
}
|
79
test/Performance/benchmark/sqlsrv/SqlsrvCRUDBench.php
Normal file
79
test/Performance/benchmark/sqlsrv/SqlsrvCRUDBench.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
use SqlsrvPerfTest\SqlsrvUtil;
|
||||
include_once __DIR__ . "/../../lib/CRUDBaseBenchmark.php";
|
||||
/**
|
||||
* @BeforeMethods({"connect", "setTableName", "createTable", "generateInsertValues", "generateUpdateValues", "generateUpdateParams"})
|
||||
* @AfterMethods({ "dropTable", "disconnect"})
|
||||
*/
|
||||
class SqlsrvCRUDBench extends CRUDBaseBenchmark
|
||||
{
|
||||
|
||||
private $conn;
|
||||
private $tableName;
|
||||
private $insertValues;
|
||||
private $updateValues;
|
||||
private $updateParams;
|
||||
|
||||
public function setTableName()
|
||||
{
|
||||
$this->tableName = "datatypes_".rand();
|
||||
}
|
||||
|
||||
public function connect()
|
||||
{
|
||||
$this->conn = SqlsrvUtil::connect();
|
||||
}
|
||||
|
||||
public function createTable()
|
||||
{
|
||||
SqlsrvUtil::createCRUDTable( $this->conn, $this->tableName );
|
||||
}
|
||||
|
||||
public function generateInsertValues()
|
||||
{
|
||||
$this->insertValues = SqlsrvUtil::generateInsertValues();
|
||||
}
|
||||
|
||||
public function generateUpdateValues()
|
||||
{
|
||||
$this->updateValues = SqlsrvUtil::generateUpdateValues();
|
||||
}
|
||||
|
||||
public function generateUpdateParams()
|
||||
{
|
||||
$this->updateParams = SqlsrvUtil::generateUpdateParams();
|
||||
}
|
||||
/**
|
||||
* Each iteration does the following $loopsPerCRUDIter times:
|
||||
* (i) insert a row into the table with insertWithPrepare
|
||||
* (ii) fetch the row with fetchWithPrepare
|
||||
* (iii) update the row's contents with updateWithPrepare
|
||||
* (iv) delete the row with delete
|
||||
* Every insertion calls prepare, bindParam and execute APIs.
|
||||
* Every fetch calls prepare, execute and fetch APIs.
|
||||
* Every update calls prepare, bindParam and execute APIs.
|
||||
* Every delete calls prepare and execute APIs.
|
||||
*/
|
||||
public function benchCRUDWithPrepare()
|
||||
{
|
||||
for( $i=0; $i<SqlsrvUtil::$loopsPerCRUDIter; $i++ )
|
||||
{
|
||||
SqlsrvUtil::insertWithPrepare( $this->conn, $this->tableName, $this->insertValues );
|
||||
SqlsrvUtil::fetchWithPrepare( $this->conn, $this->tableName );
|
||||
$stmt = SqlsrvUtil::updateWithPrepare( $this->conn, $this->tableName, $this->updateValues, $this->updateParams );
|
||||
SqlsrvUtil::delete( $this->conn, $this->tableName );
|
||||
}
|
||||
}
|
||||
|
||||
public function dropTable()
|
||||
{
|
||||
SqlsrvUtil::dropTable( $this->conn, $this->tableName );
|
||||
}
|
||||
|
||||
public function disconnect()
|
||||
{
|
||||
SqlsrvUtil::disconnect( $this->conn );
|
||||
}
|
||||
|
||||
}
|
|
@ -122,6 +122,7 @@ def get_test_name( name ):
|
|||
test_name_dict = {
|
||||
'SqlsrvConnectionBench': 'connection'
|
||||
, 'SqlsrvCreateDbTableProcBench': 'create'
|
||||
, 'SqlsrvCRUDBench': 'crud'
|
||||
, 'SqlsrvInsertBench': 'crud-create'
|
||||
, 'SqlsrvFetchBench': 'crud-retrieve'
|
||||
, 'SqlsrvUpdateBench': 'crud-update'
|
||||
|
@ -130,6 +131,7 @@ def get_test_name( name ):
|
|||
, 'SqlsrvSelectVersionBench': 'version'
|
||||
, 'PDOConnectionBench': 'connection'
|
||||
, 'PDOCreateDbTableProcBench': 'create'
|
||||
, 'PDOCRUDBench': 'crud'
|
||||
, 'PDOInsertBench': 'crud-create'
|
||||
, 'PDOFetchBench': 'crud-retrieve'
|
||||
, 'PDOUpdateBench': 'crud-update'
|
||||
|
|
Loading…
Reference in a new issue