-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathperf-test-groupmatch.sql
74 lines (54 loc) · 1.51 KB
/
perf-test-groupmatch.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
-- Performance test - RegexMatch()
*/
-- TEST 1: A SIMPLE REGEX MATCH
if object_id('tempdb..#results') is not null
begin
exec ('drop table #results');
end
go
declare @StartTime datetime, @EndTime datetime
set @StartTime = getdate();
;WITH x AS
(
SELECT TOP (1000) [object_id], name from sys.all_objects
)
SELECT n = ROW_NUMBER() OVER (ORDER BY x.[object_id])
,MatchedName = dbo.RegexGroupMatch(x.name + y.name,'(?<firstfour>\w{4})','firstfour')
into #results
FROM x CROSS JOIN x AS y ORDER BY n;
set @EndTime = getdate();
drop table #results;
select RunTimeInSec = datediff(ms, @StartTime,@EndTime) / 1000.0
go 10
-- TEST 2: A COMPLEX, SLOW REGEX MATCH
if object_id('tempdb..#results') is not null
begin
exec ('drop table #results');
end
go
declare @StartTime datetime, @EndTime datetime
set @StartTime = getdate();
;WITH x AS
(
SELECT TOP (1000) [object_id], name from sys.all_objects
)
SELECT n = ROW_NUMBER() OVER (ORDER BY x.[object_id])
,MatchedName = dbo.RegexGroupMatch(x.name + y.name,'(?<firstsix>(\w{4}\w?\w{1}))\S+','firstsix')
into #results
FROM x CROSS JOIN x AS y ORDER BY n;
set @EndTime = getdate();
drop table #results;
select RunTimeInSec = datediff(ms, @StartTime,@EndTime) / 1000.0
go 10
/*
;WITH x AS
(
SELECT TOP (1000) [object_id], name from sys.all_objects
)
SELECT n = ROW_NUMBER() OVER (ORDER BY x.[object_id])
--,x.name
--,y.name
,MatchedName = dbo.RegexGroupMatch(x.name + y.name,'(?<firstfour>(\w{4}\w?\w{1}))\S+','firstfour')
FROM x CROSS JOIN x AS y ORDER BY n;
*/