Skip to content

Commit e64af99

Browse files
authored
Add some documentation information
1 parent 7791f06 commit e64af99

File tree

1 file changed

+35
-24
lines changed

1 file changed

+35
-24
lines changed

Stored_Procedure/dbo.sp_BenchmarkTSQL.sql

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,40 +21,51 @@ ALTER PROCEDURE dbo.sp_BenchmarkTSQL(
2121
)
2222
/*
2323
.SYNOPSIS
24-
Run TSQL statement @numberOfExecution times and calculate execution time, save results if needed or print it.
24+
Run TSQL statement @numberOfExecution times and calculate each execution time, save results if needed or print it.
2525
2626
.DESCRIPTION
2727
Run SQL statement specified times, show results, insert execution details into log table master.dbo.BenchmarkTSQL.
2828
2929
.PARAMETER @tsqlStatementBefore
30-
TSQL statement that executed before tested main TSQL statement - not taken into account when measuring @tsqlStatement. Default is NULL.
30+
TSQL statement that executed before tested main TSQL statement - not taken into account when measuring @tsqlStatement.
31+
Default value is NULL.
3132
3233
.PARAMETER @tsqlStatement
3334
TSQL statement for benchmarking. Mandatory parameter.
35+
No defaults.
3436
3537
.PARAMETER @tsqlStatementAfter
36-
TSQL statement that executed after tested TSQL statement - not taken into account when measuring @tsqlStatement. Default is NULL.
38+
TSQL statement that executed after tested TSQL statement - not taken into account when measuring @tsqlStatement.
39+
Default value is NULL.
3740
3841
.PARAMETER @numberOfExecution
3942
Number of execution TSQL statement.
43+
Default value is 10.
4044
4145
.PARAMETER @saveResults
42-
Save benchmark details to master.dbo.BenchmarkTSQL table if @saveResults = 1. Create table if not exists (see 301 line: CREATE TABLE master.dbo.BenchmarkTSQL …).
46+
Save benchmark details to master.dbo.BenchmarkTSQL table if @saveResults = 1.
47+
Create table if not exists (see 301 line: CREATE TABLE master.dbo.BenchmarkTSQL …).
48+
Default value is 0 - not saved.
4349
4450
.PARAMETER @skipTSQLCheck
45-
Checking for valid TSQL statement. Default value is 1 (true) - skip checking.
51+
Checking for valid TSQL statement.
52+
Default value is 1 (true) - skip checking.
4653
4754
.PARAMETER @clearCache
48-
Clear cached plan for TSQL statement. Default value is 0 (false) - not clear.
55+
Clear cached plan for TSQL statement before each run.
56+
Default value is 0 (false) - not clear.
4957
5058
.PARAMETER @calcMedian
51-
Calculate pseudo median of execution time. Default value is 0 (false) - not calculated.
59+
Calculate pseudo median of all execution times.
60+
Default value is 0 (false) - not calculated.
5261
5362
.PARAMETER @printStepInfo
54-
PRINT detailed step information: step count, start time, end time, duration. Default value is 0.
63+
PRINT detailed step information: step count, start time, end time, duration.
64+
Default value is 0 - not printed.
5565
5666
.PARAMETER @durationAccuracy
57-
Duration accuracy calculation, possible values for this stored procedure parameter: ns, mcs, ms, ss, mi, hh, dd, wk. Default value is ss - seconds.
67+
Duration accuracy calculation, possible values for this stored procedure parameter: ns, mcs, ms, ss, mi, hh, dd, wk.
68+
Default value is ss - seconds.
5869
See DATEDIFF https://docs.microsoft.com/en-us/sql/t-sql/functions/datediff-transact-sql
5970
6071
.PARAMETER @dateTimeFunction
@@ -127,7 +138,7 @@ ALTER PROCEDURE dbo.sp_BenchmarkTSQL(
127138

128139
.EXAMPLE
129140
WITH CTE AS (
130-
SELECT TSQLStatementGUID
141+
SELECT TSQLStatementGUID
131142
, StartBenchmark
132143
, EndBenchmark
133144
, ClearCache
@@ -161,10 +172,10 @@ ALTER PROCEDURE dbo.sp_BenchmarkTSQL(
161172
, TsqlStatementAfter
162173
, OriginalLogin
163174
, AdditionalInfo
164-
FROM master.dbo.BenchmarkTSQL
165-
WHERE TSQLStatementGUID IN ('D34C4BD6-01B8-4C9C-B627-E3C26F84D9FA', '02DF082C-7D3D-450E-B125-C738F015B35A')
175+
FROM master.dbo.BenchmarkTSQL
176+
WHERE TSQLStatementGUID IN ('D34C4BD6-01B8-4C9C-B627-E3C26F84D9FA', '02DF082C-7D3D-450E-B125-C738F015B35A')
166177
)
167-
SELECT TSQLStatementGUID
178+
SELECT TSQLStatementGUID
168179
, StartBenchmark
169180
, EndBenchmark
170181
, ClearCache
@@ -176,23 +187,23 @@ ALTER PROCEDURE dbo.sp_BenchmarkTSQL(
176187
, MAX(StepDuration) AS StepDurationMAX
177188
, AVG(StepDuration) AS StepDurationAVG
178189
, TsqlStatement
179-
FROM CTE
180-
GROUP BY TSQLStatementGUID
181-
, StartBenchmark
182-
, EndBenchmark
183-
, ClearCache
184-
, PrintStepInfo
185-
, DurationAccuracy
186-
, BenchmarkDuration
187-
, TsqlStatement;
190+
FROM CTE
191+
GROUP BY TSQLStatementGUID
192+
, StartBenchmark
193+
, EndBenchmark
194+
, ClearCache
195+
, PrintStepInfo
196+
, DurationAccuracy
197+
, BenchmarkDuration
198+
, TsqlStatement;
188199

189200
.LICENSE MIT
190201
Permission is here by granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
191202
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
192203
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
193204

194205
.NOTE
195-
Version: 5.5
206+
Version: 5.7
196207
Created: 2017-12-14 by Konstantin Taranov
197208
Modified: 2019-04-18 by Konstantin Taranov
198209
Main contributors: Konstantin Taranov, Aleksei Nagorskii
@@ -632,7 +643,7 @@ BEGIN CATCH
632643
'. Try to use @durationAccuracy with a less precise datepart - seconds (ss) or minutes (mm) or days (dd).' + @crlf +
633644
'But in log table master.dbo.BenchmarkTSQL (if you run stored procedure with @saveResult = 1) all times saving with datetime2(7) precise!' + @crlf +
634645
'You can manualy calculate difference after decreasing precise datepart.' + @crlf +
635-
'For analyze log table see latest examples in document section.') + @crlf + + @crlf;
646+
'For analyze log table see latest example in document section.') + @crlf + + @crlf;
636647
END CATCH;
637648
GO
638649

0 commit comments

Comments
 (0)