PStSQLtTestGenerator icon indicating copy to clipboard operation
PStSQLtTestGenerator copied to clipboard

Create test to test query speed

Open sanderstad opened this issue 6 years ago • 0 comments

Create a command to create a unit test that tests a specific query. Get the first run time, then execute the query X times to get an average.

DECLARE @t1 DATETIME;
DECLARE @t2 DATETIME;

SET @t1 = GETDATE();
SELECT /* query one */ 1 ;
SET @t2 = GETDATE();
SELECT DATEDIFF(millisecond,@t1,@t2) AS elapsed_ms;

SET @t1 = GETDATE();
SELECT /* query two */ 2 ;
SET @t2 = GETDATE();
SELECT DATEDIFF(millisecond,@t1,@t2) AS elapsed_ms

sanderstad avatar Oct 05 '19 11:10 sanderstad