|
nsz |
c3ad4e |
#include <stdio.h>
|
|
nsz |
c3ad4e |
#include <stdlib.h>
|
|
nsz |
c3ad4e |
#include <string.h>
|
|
nsz |
c3ad4e |
#include <regex.h>
|
|
nsz |
c3ad4e |
#include <locale.h>
|
|
nsz |
c3ad4e |
#include "test.h"
|
|
nsz |
c3ad4e |
|
|
nsz |
c3ad4e |
|
|
nsz |
c3ad4e |
void bench_regex_compile(int N) {
|
|
nsz |
c3ad4e |
regex_t re;
|
|
nsz |
c3ad4e |
int i;
|
|
nsz |
c3ad4e |
|
|
nsz |
c3ad4e |
setlocale(LC_CTYPE, "");
|
|
nsz |
c3ad4e |
for (i=0; i
|
|
nsz |
c3ad4e |
regcomp(&re, "(a|b|c)*d*b", REG_EXTENDED);
|
|
nsz |
c3ad4e |
regfree(&re);
|
|
nsz |
c3ad4e |
}
|
|
nsz |
c3ad4e |
}
|
|
nsz |
c3ad4e |
|
|
nsz |
c3ad4e |
static void regex_search(int N, char *s) {
|
|
nsz |
c3ad4e |
char buf[100000];
|
|
nsz |
c3ad4e |
regex_t re;
|
|
nsz |
c3ad4e |
int i;
|
|
nsz |
c3ad4e |
|
|
nsz |
c3ad4e |
setlocale(LC_CTYPE, "");
|
|
nsz |
c3ad4e |
memset(buf, 'a', sizeof(buf)-2);
|
|
nsz |
c3ad4e |
buf[sizeof buf - 2] = 'b';
|
|
nsz |
c3ad4e |
buf[sizeof buf - 1] = 0;
|
|
nsz |
c3ad4e |
regcomp(&re, s, REG_EXTENDED);
|
|
nsz |
c3ad4e |
for (i=0; i
|
|
nsz |
c3ad4e |
regexec(&re, buf, 0, 0, 0);
|
|
nsz |
c3ad4e |
regfree(&re);
|
|
nsz |
c3ad4e |
}
|
|
nsz |
c3ad4e |
|
|
nsz |
c3ad4e |
void bench_regex_search1(int N) {
|
|
nsz |
c3ad4e |
regex_search(N, "(a|b|c)*d*b");
|
|
nsz |
c3ad4e |
}
|
|
nsz |
c3ad4e |
|
|
nsz |
c3ad4e |
void bench_regex_search2(int N) {
|
|
nsz |
c3ad4e |
regex_search(N, "a{25}b");
|
|
nsz |
c3ad4e |
}
|