Merge pull request #512 from david-puglielli/suse-performance-test

Added SUSE 12 and CRUD to performance tests
This commit is contained in:
David Puglielli 2017-08-29 15:30:53 -04:00 committed by GitHub
commit 9e695d2d57
10 changed files with 209 additions and 23 deletions

View file

@ -15,6 +15,8 @@ Run `Windows PowerShell` as administrator.
sudo env "PATH=$PATH" bash setup_env_unix.sh Ubuntu16 <PHP_VERSION - 7.x.y> <PHP_THREAD - ts or nts> <absolute path to the SQLSRV driver so> <absolute path to the PDO_SQLSRV driver so>
### RedHat 7
sudo env "PATH=$PATH" bash setup_env_unix.sh RedHat7 <PHP_VERSION - 7.x.y> <PHP_THREAD - ts or nts> <absolute path to the SQLSRV driver so> <absolute path to the PDO_SQLSRV driver so>
### SUSE 12
sudo env "PATH=$PATH" bash setup_env_unix.sh SUSE12 <PHP_VERSION - 7.x.y> <PHP_THREAD - ts or nts> <absolute path to the SQLSRV driver so> <absolute path to the PDO_SQLSRV driver so>
### MacOS 10.12 Sierra
`brew` cannot be run with `sudo` on Sierra. Either enable passwordless `sudo` on the machine or enter the password when prompted.
@ -30,10 +32,10 @@ PHPBench is used to run the benchmarks. Visit http://phpbench.readthedocs.io/en/
### Windows
py.exe run-perf_tests.py -platform <PLATFORM>
### Linux and Mac
On Linux and Mac, the script must be executed with `sudo python3` because to enable pooling it needs to modify odbcinst.ini system file. As an improvement, the location of the odbcinst.ini file can be changed so that, sudo is not requiered.
On Linux and Mac, the script must be executed with `sudo python3` because to enable pooling it needs to modify odbcinst.ini system file. As an improvement, the location of the odbcinst.ini file can be changed so that sudo is not required.
python3 run-perf_tests.py -platform <PLATFORM> | tee run-perf_output.txt
`-platform` - The platform that the tests are ran on. Must be one of the following: Windows10, WindowsServer2016, WindowsServer2012, Ubuntu16, RedHat7, Sierra.
`-platform` - The platform that the tests are ran on. Must be one of the following: Windows10, WindowsServer2016, WindowsServer2012, Ubuntu16, RedHat7, SUSE12, Sierra.
`-php-driver` (optional) - The driver that the tests are ran on. Must be one of the following: sqlsrv, pdo_sqlsrv, or both. Default is both.
`-testname` (optional) - The test to run. Must be the file name (not including path) of one test or 'all'. Default is 'all'. If one test is specified, must also specify the -php-driver option to sqlsrv or pdo_sqlsrv.

View 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 );
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 );
}
}

View file

@ -23,7 +23,7 @@ class PDOFetchLargeBench
$this->conn = PDOSqlsrvUtil::connect();
}
/*
* Each iteration calls prepare, execute and fetch APIs to fetch the already populdated data
* Each iteration calls prepare, execute and fetch APIs to fetch the already populated data
*/
public function benchFetchWithPrepare()
{

View file

@ -57,7 +57,7 @@ class PDOUpdateBench extends CRUDBaseBenchmark
{
for( $i=0; $i<PDOSqlsrvUtil::$loopsPerCRUDIter; $i++ )
{
$stmt = PDOSqlsrvUtil::updateWithPrepare( $this->conn, $this->tableName, $this->updateValues, $this->updateParams );
PDOSqlsrvUtil::updateWithPrepare( $this->conn, $this->tableName, $this->updateValues, $this->updateParams );
}
}

View 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 );
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 );
}
}

View file

@ -23,7 +23,7 @@ class SqlsrvFetchLargeBench
$this->conn = SqlsrvUtil::connect();
}
/*
* Each iteration calls prepare, execute and fetch APIs to fetch the already populdated data
* Each iteration calls prepare, execute and fetch APIs to fetch the already populated data
*/
public function benchFetchWithPrepare()
{

View file

@ -57,7 +57,7 @@ class SqlsrvUpdateBench extends CRUDBaseBenchmark
{
for( $i=0; $i<SqlsrvUtil::$loopsPerCRUDIter; $i++ )
{
$stmt = SqlsrvUtil::updateWithPrepare( $this->conn, $this->tableName, $this->updateValues, $this->updateParams );
SqlsrvUtil::updateWithPrepare( $this->conn, $this->tableName, $this->updateValues, $this->updateParams );
}
}

View file

@ -58,6 +58,7 @@ def validate_platform( platform_name ):
, "WindowsServer2012"
, "Ubuntu16"
, "RedHat7"
, "SUSE12"
, "Sierra"]
if platform_name not in platforms:
print ( "Platform must be one of the following:" )
@ -121,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'
@ -129,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'

View file

@ -2,10 +2,10 @@
set -e
if [[ ("$1" = "Ubuntu16" || "$1" = "RedHat7" || "$1" = "Sierra") ]]; then
if [[ ("$1" = "Ubuntu16" || "$1" = "RedHat7" || "$1" = "SUSE12" || "$1" = "Sierra") ]]; then
PLATFORM=$1
else
echo "1st argument must be one of Ubuntu16, RedHat7, Sierra. Exiting..."
echo "1st argument must be one of Ubuntu16, RedHat7, SUSE12, Sierra. Exiting..."
exit 1
fi
@ -24,7 +24,7 @@ else
fi
if [[ (! -f "$4") || (! -f "$5") ]]; then
echo "5th and 6th argument must be paths to sqlsrv and pdo drivers. Exiting..."
echo "4th and 5th argument must be paths to sqlsrv and pdo drivers. Exiting..."
exit 1
else
SQLSRV_DRIVER=$4
@ -61,8 +61,8 @@ elif [ $PLATFORM = "RedHat7" ]; then
printf "Enabling EPEL repo..."
# pipe non-error to log file (wget and yum install reports error when there's nothing to do)
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm >> env_setup.log 2>&1
yes | sudo yum install epel-release-latest-7.noarch.rpm >> env_setup.log 2>&1 || true
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm >> env_setup.log
yes | sudo yum install epel-release-latest-7.noarch.rpm >> env_setup.log || true
printf "done\n"
printf "Installing python34-setuptools..."
@ -83,6 +83,28 @@ elif [ $PLATFORM = "RedHat7" ]; then
pip3 install --upgrade pip >> env_setup.log
pip3 install pyodbc >> env_setup.log
printf "done\n"
elif [ $PLATFORM = "SUSE12" ]; then
printf "Update..."
sudo zypper refresh >> env_setup.log
printf "done\n"
printf "Installing autoconf, gcc, g++, git, zip, libxml, openssl, python3, pip3..."
sudo zypper -n install autoconf gcc gcc-c++ libxml2-devel git zip libopenssl-devel python3-devel python3-pip python3-setuptools >> env_setup.log
printf "done\n"
printf "Installing MSODBCSQL..."
zypper -n ar https://packages.microsoft.com/config/sles/12/prod.repo
zypper --gpg-auto-import-keys refresh
ACCEPT_EULA=Y zypper -n install msodbcsql >> env_setup.log
ACCEPT_EULA=Y zypper -n install mssql-tools >> env_setup.log
zypper -n install unixODBC-devel >> env_setup.log
printf "done\n"
printf "Installing pyodbc"
pip3 install --upgrade pip >> env_setup.log
pip3 install pyodbc >> env_setup.log
printf "done\n"
elif [ $PLATFORM = "Sierra" ]; then
printf "Installing homebrew..."
@ -120,7 +142,7 @@ fi
printf "Downloading PHP-$PHP_VERSION source tarball..."
# pipe non-error to log file
wget http://ca1.php.net/get/php-$PHP_VERSION.tar.gz/from/this/mirror -O php-$PHP_VERSION.tar.gz >> env_setup.log 2>&1
wget http://ca1.php.net/get/php-$PHP_VERSION.tar.gz/from/this/mirror -O php-$PHP_VERSION.tar.gz >> env_setup.log
printf "done\n"
printf "Extracting PHP source tarball..."
@ -132,7 +154,7 @@ phpDir=php-$PHP_VERSION
cd $phpDir
printf "Configuring PHP..."
./buildconf --force >> ../env_setup.log 2>&1
./buildconf --force >> ../env_setup.log
CONFIG_OPTIONS="--enable-cli --enable-cgi --with-zlib --enable-mbstring --prefix=/usr/local"
[ "${PHP_THREAD}" == "ts" ] && CONFIG_OPTIONS=${CONFIG_OPTIONS}" --enable-maintainer-zts"
if [ $PLATFORM = "Sierra" ]; then
@ -141,7 +163,7 @@ else
CONFIG_OPTIONS=$CONFIG_OPTIONS" --with-openssl"
fi
#pipe non-error to log file
(./configure $CONFIG_OPTIONS >> ../env_setup.log 2>&1)
(./configure $CONFIG_OPTIONS >> ../env_setup.log)
printf "done\n"
printf "Compiling and installing PHP..."
@ -158,12 +180,12 @@ cp php.ini-production php.ini
driverName=$(basename $SQLSRV_DRIVER)
echo "extension=$driverName" >> php.ini
sudo cp -r $SQLSRV_DRIVER $phpExtDir/$driverName
sudo chmod a+r $SQLSRV_DRIVER $phpExtDir/$driverName
sudo chmod a+r $phpExtDir/$driverName
driverName=$(basename $PDO_DRIVER)
echo "extension=$driverName" >> php.ini
sudo cp -r $PDO_DRIVER $phpExtDir/$driverName
sudo chmod a+r $SQLSRV_DRIVER $phpExtDir/$driverName
sudo chmod a+r $phpExtDir/$driverName
sudo cp php.ini /usr/local/lib
printf "done\n"
@ -175,7 +197,7 @@ printf "done\n"
printf "Installing Composer..."
cd ..
# pipe non-error to log file
wget https://getcomposer.org/installer -O composer-setup.php >> env_setup.log 2>&1
wget https://getcomposer.org/installer -O composer-setup.php >> env_setup.log
/usr/local/bin/php composer-setup.php >> env_setup.log
printf "done\n"

View file

@ -41,18 +41,19 @@ $phpDir="C:\php"
Remove-Item $phpDir -Recurse -ErrorAction Ignore
New-Item -ItemType directory -Path $phpDir
Expand-Archive $PHP_ZIP -DestinationPath $phpDir
Copy-Item $SQLSRV_DRIVER $phpDir\ext
Copy-Item $PDO_DRIVER $phpDir\ext
# copy drivers to extensions directory and rename to a standard nomenclature
# for consistency with run-perf_tests.py
Copy-Item $SQLSRV_DRIVER $phpDir\ext\php_sqlsrv.dll
Copy-Item $PDO_DRIVER $phpDir\ext\php_pdo_sqlsrv.dll
# setup driver
Copy-Item $phpDir\php.ini-production $phpDir\php.ini
Add-Content $phpDir\php.ini "extension=$phpDir\ext\php_openssl.dll"
Add-Content $phpDir\php.ini "extension=$phpDir\ext\php_mbstring.dll"
$driverName=Split-Path $SQLSRV_DRIVER -leaf
Add-Content $phpDir\php.ini "extension=$phpDir\ext\$driverName"
$driverName=Split-Path $PDO_DRIVER -leaf
Add-Content $phpDir\php.ini "extension=$phpDir\ext\$driverName"
Add-Content $phpDir\php.ini "extension=$phpDir\ext\php_sqlsrv.dll"
Add-Content $phpDir\php.ini "extension=$phpDir\ext\php_pdo_sqlsrv.dll"
Move-Item $phpDir\php.ini C:\Windows -force
Copy-Item $phpDir\ssleay32.dll C:\Windows -force