Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DECLARE @Test1 int, @Test2 int, @Test3 int, @TestVar1 int, @TestVar2 int
- DECLARE @Loop int, @Start datetime, @CTR int, @TimesToLoop1 int, @TimesToLoop2 int
- SET @Test1 = 0
- SET @Test2 = 0
- SET @Test3 = 0
- SET @Loop = 0
- SET @TestVar2 = 0
- SET @TimesToLoop1 = 10
- SET @TimesToLoop2 = 50000
- WHILE @Loop < @TimesToLoop1
- BEGIN
- SET @Start = CURRENT_TIMESTAMP
- SET @CTR = 0
- /* Testing the performance of SET */
- WHILE @CTR < @TimesToLoop2
- BEGIN
- SET @TestVar1 = 1
- SET @TestVar2 = @TestVar2 - @TestVar1
- SET @CTR = @CTR + 1
- END
- SET @Loop = @Loop + 1
- SET @Test1 = @Test1 + DATEDIFF(ms, @Start, CURRENT_TIMESTAMP)
- END
- SET @Loop = 0
- SET @TestVar2 = 0
- WHILE @Loop < @TimesToLoop1
- BEGIN
- SELECT @Start = CURRENT_TIMESTAMP
- SELECT @CTR = 0
- /* Testing the performance of SELECT */
- WHILE @CTR < @TimesToLoop2
- BEGIN
- SELECT @TestVar1 = 1
- SELECT @TestVar2 = @TestVar2 - @TestVar1
- SELECT @CTR = @CTR + 1
- END
- SELECT @Loop = @Loop + 1
- SELECT @Test2 = @Test2 + DATEDIFF(ms, @Start, CURRENT_TIMESTAMP)
- END
- SET @Loop = 0
- SET @TestVar2 = 0
- WHILE @Loop < @TimesToLoop1
- BEGIN
- SELECT @Start = CURRENT_TIMESTAMP, @CTR = 0
- /* Testing the performance of SELECT with multiple variable assignments */
- WHILE @CTR < @TimesToLoop2
- BEGIN
- SELECT @TestVar1 = 1, @TestVar2 = @TestVar2 - @TestVar1, @CTR = @CTR + 1
- END
- SELECT @Loop = @Loop + 1, @Test3 = @Test3 + DATEDIFF(ms, @Start, CURRENT_TIMESTAMP)
- END
- SELECT (@Test1/CAST(@TimesToLoop1 AS decimal(7,2)))/1000.00 AS [SET],
- (@Test2/CAST(@TimesToLoop1 AS decimal(7,2)))/1000.00 AS [SELECT],
- (@Test3/CAST(@TimesToLoop1 AS decimal(7,2)))/1000.00 AS [SELECT with Multiple Assignments]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement