The R Project SVN R

Rev

Rev 77976 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 77976 Rev 78707
Line 7... Line 7...
7
 
7
 
8
## This is expected to throw a warning at some point if PCRE uses a stack,
8
## This is expected to throw a warning at some point if PCRE uses a stack,
9
## depending on the system and stack size.
9
## depending on the system and stack size.
10
## Typical stack 8-10M, some people use 40M.
10
## Typical stack 8-10M, some people use 40M.
11
 
11
 
-
 
12
## PCRE2 >= 10.30 never uses recursion: earlier versions (including
12
pcre_config()["stack"]
13
## PCRE1) can be compiled not to use a stack.
13
 
14
 
14
op <- options(warn = 1)
15
unname(pcre_config()["stack"])
15
for (n in c(seq(5000L, 10000L, 1000L), 20000L, 50000L, 100000L)) {
-
 
16
    print(n)
-
 
17
    x <- paste0(rep("a", n), collapse="")
-
 
18
    print(grepl("(a|b)+", x, perl = TRUE))
-
 
19
}
-
 
20
options(op)
-
 
21
 
16
 
-
 
17
if(pcre_config()["stack"]) {
-
 
18
    op <- options(warn = 1)
-
 
19
    for (n in c(seq(5000L, 10000L, 1000L), 20000L, 50000L, 100000L)) {
-
 
20
        print(n)
-
 
21
        x <- paste0(rep("a", n), collapse="")
-
 
22
        print(grepl("(a|b)+", x, perl = TRUE))
-
 
23
    }
-
 
24
    options(op)
-
 
25
}
22
 
26
 
23
### tests of PCRE's JIT.
27
### tests of PCRE's JIT.
24
if(!pcre_config()["JIT"]) {
28
if(!pcre_config()["JIT"]) {
25
    message("These tests are pointless without JIT support")
29
    message("The rest of these tests are pointless without JIT support")
26
    q("no")
30
    q("no")
27
}
31
}
28
 
32
 
29
## Test from example(grep)
33
## Test from example(grep)
30
 
34
 
Line 68... Line 72...
68
options(PCRE_use_JIT = FALSE)
72
options(PCRE_use_JIT = FALSE)
69
st(for(i in 1:1e4) gsub("(\\w)(\\w*)", "\\U\\1\\L\\2", txt, perl = TRUE))
73
st(for(i in 1:1e4) gsub("(\\w)(\\w*)", "\\U\\1\\L\\2", txt, perl = TRUE))
70
options(PCRE_use_JIT = TRUE)
74
options(PCRE_use_JIT = TRUE)
71
st(for(i in 1:1e4) gsub("(\\w)(\\w*)", "\\U\\1\\L\\2", txt, perl = TRUE))
75
st(for(i in 1:1e4) gsub("(\\w)(\\w*)", "\\U\\1\\L\\2", txt, perl = TRUE))
72
 
76
 
73
if(grepl("^10", extSoftVersion()["PCRE"])) q()
77
if(grepl("^10", extSoftVersion()["PCRE"])) {
-
 
78
    cat("Time elapsed: ", proc.time() - .ptime,"\n")
-
 
79
    q()
-
 
80
}
74
 
81
 
75
### previous test suite for PCRE1
82
### previous test suite for PCRE1
76
## here JIT is slightly slower
83
## here JIT is slightly slower
77
options(PCRE_study = FALSE, PCRE_use_JIT = FALSE)
84
options(PCRE_study = FALSE, PCRE_use_JIT = FALSE)
78
st(for(i in 1:1e4) grep("[gu]", txt2, perl = TRUE))
85
st(for(i in 1:1e4) grep("[gu]", txt2, perl = TRUE))