USE PerfTest; SET NOCOUNT ON; GO TRUNCATE TABLE dbo.CardNoEncrypt; TRUNCATE TABLE dbo.CardEncryptByCert; TRUNCATE TABLE dbo.CardEncryptByKey; /* ============================================================================================ */ /* ================================ Load and Read ============================================= */ /* ============================================================================================ */ DECLARE @createMax int; DECLARE @delaySeconds char(8); DECLARE @durEncryptNone int; DECLARE @durEncryptCert int; DECLARE @durEncryptKey int; DECLARE @durCreateNone int; DECLARE @durCreateCert int; DECLARE @durCreateKey int; DECLARE @durReadNone int; DECLARE @durReadCert int; DECLARE @durReadKey int; DECLARE @print bit; DECLARE @readByIDMax int; DECLARE @readByNumberMax int; DECLARE @testCert CertID; DECLARE @testKey KeyGUID; SELECT @testCert = Cert_ID('PerfTestCert'), @testKey = Key_GUID('PerfTestKey'), @delaySeconds = '00:00:05', @print = 1, @createMax = 10000, @readByIDMax = @createMax; SELECT @durCreateNone = 0, @durCreateCert = 0, @durCreateKey = 0, @durReadNone = 0, @durReadCert = 0, @durReadKey = 0; OPEN SYMMETRIC KEY PerfTestKey DECRYPTION BY CERTIFICATE PerfTestCert; PRINT '' SELECT @testKey AS '@testKey', @testCert AS '@testCert'; -- ============== CardCreate WAITFOR DELAY @delaySeconds EXEC dbo.CardCreateLoopN @Max = @createMax, @EncryptionType = 'None', @CertID = @testCert, @KeyGUID = @testKey, @Print = @print, @MsDuration = @durCreateNone OUTPUT; RAISERROR('CardCreateLoopN Unencrypted Complete', 10, 1) WITH NOWAIT; WAITFOR DELAY @delaySeconds EXEC dbo.CardCreateLoopN @Max = @createMax, @EncryptionType = 'ByCert', @CertID = @testCert, @KeyGUID = @testKey, @Print = @print, @MsDuration = @durCreateCert OUTPUT; RAISERROR('CardCreateLoopN EncryptByCert Complete', 10, 1) WITH NOWAIT; WAITFOR DELAY @delaySeconds EXEC dbo.CardCreateLoopN @Max = @createMax, @EncryptionType = 'ByKey', @CertID = @testCert, @KeyGUID = @testKey, @Print = @print, @MsDuration = @durCreateKey OUTPUT; RAISERROR('CardCreateLoopN EncryptByKey Complete', 10, 1) WITH NOWAIT; -- CardCreate Results SELECT @durEncryptNone = @durCreateNone, @durEncryptCert = @durCreateCert, @durEncryptKey = @durCreateKey; IF @durEncryptNone <> 0 BEGIN PRINT '' SELECT ((1.0 * @durEncryptCert) / @durEncryptNone) AS [EncryptCost:Create:Cert]; SELECT ((1.0 * @durEncryptKey) / @durEncryptNone) AS [EncryptCost:Create:Key]; END; ELSE BEGIN PRINT '' PRINT 'Unencrypted create duration is 0 ms'; END; -- ============== CardReadByID WAITFOR DELAY @delaySeconds EXEC dbo.CardReadByIDLoopN @CardMax = @createMax, @ReadMax = @readByIDMax, @EncryptionType = 'None', @CertID = @testCert, @Print = @print, @MsDuration = @durReadNone OUTPUT; RAISERROR('CardReadByIDLoopN Unencrypted Complete', 10, 1) WITH NOWAIT; WAITFOR DELAY @delaySeconds EXEC dbo.CardReadByIDLoopN @CardMax = @createMax, @ReadMax = @readByIDMax, @EncryptionType = 'ByCert', @CertID = @testCert, @Print = @print, @MsDuration = @durReadCert OUTPUT; RAISERROR('CardReadByIDLoopN EncryptByCert Complete', 10, 1) WITH NOWAIT; WAITFOR DELAY @delaySeconds EXEC dbo.CardReadByIDLoopN @CardMax = @createMax, @ReadMax = @readByIDMax, @EncryptionType = 'ByKey', @CertID = @testCert, @Print = @print, @MsDuration = @durReadKey OUTPUT; RAISERROR('CardReadByIDLoopN EncryptByKey Complete', 10, 1) WITH NOWAIT; -- CardReadByID Results SELECT @durEncryptNone = @durReadNone, @durEncryptCert = @durReadCert, @durEncryptKey = @durReadKey; IF @durEncryptNone <> 0 BEGIN PRINT '' SELECT ((1.0 * @durEncryptCert) / @durEncryptNone) AS [EncryptCost:Read:Cert]; SELECT ((1.0 * @durEncryptKey) / @durEncryptNone) AS [EncryptCost:Read:Key]; END; ELSE BEGIN PRINT '' PRINT 'Unencrypted read duration is 0 ms'; END; -- Total Results SELECT @durEncryptNone = @durCreateNone + @durReadNone, @durEncryptCert = @durCreateCert + @durReadCert, @durEncryptKey = @durCreateKey + @durReadKey; IF @durEncryptNone <> 0 BEGIN SELECT ((1.0 * @durEncryptCert) / @durEncryptNone) AS [EncryptCost:Total:Cert]; SELECT ((1.0 * @durEncryptKey) / @durEncryptNone) AS [EncryptCost:Total:Key]; END; ELSE BEGIN PRINT '' PRINT 'Unencrypted total duration is 0 ms'; END; SELECT @durCreateNone AS 'CreateNone', @durCreateCert AS 'CreateCert', @durCreateKey AS 'CreateKey', @durReadNone AS 'ReadNone', @durReadCert AS 'ReadCert', @durReadKey AS 'ReadKey'; PRINT '<< DONE >>' GO