11/08/2014
At work I'm responsible for anything that runs on electricity.
And thus also our SQL Server. In order to find a guideline of maximum batch requests per sec. So after some research (read Googling) on the internet I've found this script:
# Configuration data
[string] $server = "SERVER"; # SQL Server Instance
[string] $database = "master"; # Database containing the BLOB data.
Clear-Host;
# Open ADO.NET Connection with Windows authentification.
$con = New-Object Data.SqlClient.SqlConnection;
$con.ConnectionString = "Data Source=$server;Initial Catalog=$database;Integrated Security=True;";
$con.open();
$sql = "SELECT COUNT(*) as result FROM sys.tables;"
#$sql = "SELECT 'Test batches per sec' AS result;"
$cmd = New-Object Data.SqlClient.SqlCommand $sql, $con;
$cmd.CommandType = [Data.CommandType]::Text;
[long] $loops = 0;
[datetime] $start = [datetime]::Now;
while ($loops -lt 100000)
{
$nil = $cmd.ExecuteScalar();
$loops++;
if (($loops % 1000) -eq 0)
{
[long] $duration = [datetime]::Now.Ticks - $start.Ticks;
[TimeSpan] $ts = New-Object TimeSpan $duration;
$durationMS = $ts.TotalMilliSeconds;
Write-Host ("Batch Request/s: " + [Math]::Round($loops / ($durationMS / 1000.0), 1));
}
}
$cmd.Dispose();
$con.Close();
$con.Dispose();
Which in turn I'm sharing with you.