php-sqlsrv/test/Performance/benchmark/sqlsrv/SqlsrvCreateDbTableProcBench.php

37 lines
1 KiB
PHP
Raw Normal View History

2017-05-06 02:32:09 +02:00
<?php
use SqlsrvPerfTest\SqlsrvUtil;
2017-08-23 01:15:33 +02:00
include_once __DIR__ . "/../../lib/CRUDBaseBenchmark.php";
2017-05-06 02:32:09 +02:00
/**
* @BeforeMethods({"connect"})
* @AfterMethods({"disconnect"})
*/
2017-08-23 01:15:33 +02:00
class SqlsrvCreateDbTableProcBench extends CRUDBaseBenchmark
{
2017-05-06 02:32:09 +02:00
private $conn;
2017-08-23 01:15:33 +02:00
public function connect()
{
2017-05-06 02:32:09 +02:00
$this->conn = SqlsrvUtil::connect();
}
/*
* Each iteration creates a database, a table and a stored procedure in that database and drops the database at the end.
* Note that, ODBC SQLExecDirect function are used to execute all the queries.
2017-05-06 02:32:09 +02:00
*/
2017-08-23 01:15:33 +02:00
public function benchCreateDbTableProc()
{
2017-05-06 02:32:09 +02:00
$randomNum = rand();
$databaseName = "test_db_$randomNum";
$tableName = "test_table_$randomNum";
$procName = "test_proc_$randomNum";
SqlsrvUtil::createDbTableProc( $this->conn, $databaseName, $tableName, $procName );
SqlsrvUtil::dropDatabase( $this->conn, $databaseName );
}
2017-08-23 01:15:33 +02:00
public function disconnect()
{
2017-05-06 02:32:09 +02:00
SqlsrvUtil::disconnect( $this->conn );
}
}