12 lines
1.2 KiB
JSON
12 lines
1.2 KiB
JSON
{
|
|
"id": "44e197f3-6a63-40ce-8e3c-1a1c18e4434d",
|
|
"prefix": "timings",
|
|
"description": "Wraps a simple timings test harness around the selected code",
|
|
"body": "/**\r\nCopyright (c) Red Gate Software Ltd 2017\r\nAll rights Reserved. Use of this code is subject to the terms of a license agreement with Red Gate Software Limited.\r\n\r\nFor more info, see https://www.red-gate.com/hub/product-learning/sql-prompt/record-t-sql-execution-times-using-sql-prompt-snippet\r\n**/\r\n\r\nDECLARE @log table\r\n(\r\n TheOrder int IDENTITY(1, 1),\r\n WhatHappened varchar(200),\r\n WhenItDid datetime2 DEFAULT GETDATE()\r\n)\r\n----start of timing\r\nINSERT INTO @log(WhatHappened)\r\nSELECT 'Starting $routine$' --place at the start\r\n \r\n$SELECTEDTEXT$$CURSOR$\r\n \r\n--where the routine you want to time ends\r\nINSERT INTO @log(WhatHappened)\r\nSELECT '$routine$ took '\r\nSELECT ending.WhatHappened, DATEDIFF(ms, starting.WhenItDid, ending.WhenItDid)\r\nFROM @log starting\r\n INNER JOIN @log ending\r\n ON ending.TheOrder = starting.TheOrder + 1\r\n--list out all the timings",
|
|
"placeholders": [
|
|
{
|
|
"name": "routine",
|
|
"defaultValue": ""
|
|
}
|
|
]
|
|
} |