Apache HTTPD
testregex.c
Go to the documentation of this file.
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18#include "apr_strings.h"
19#include "apr_pools.h"
20#include "apr_general.h"
21#include "apr_hash.h"
22#include "apr_lib.h"
23#include "apr_time.h"
24#include <regex.h>
25#include <stdio.h>
26#include <stdlib.h>
27
28int main( int argc, char** argv) {
31 int rc;
32 int i;
33 int iters;
37
38
39 if (argc !=4 ) {
40 fprintf(stderr, "Usage %s match string #iterations\n",argv[0]);
41 return -1;
42 }
43 iters = atoi( argv[3]);
44
48 fprintf(stderr, "Something went wrong\n");
49 exit(-1);
50 }
52
53
54 if (rc) {
55 char errbuf[2000];
56 regerror(rc, &regex,errbuf,2000);
57 fprintf(stderr,"Couldn't compile regex ;(\n%s\n ",errbuf);
58 return -1;
59 }
60 if ( regexec( &regex, argv[2], 0, NULL,0) == 0 ) {
61 fprintf(stderr,"Match\n");
62 }
63 else {
64 fprintf(stderr,"No Match\n");
65 }
66 now = apr_time_now();
67 for (i=0;i<iters;i++) {
68 regexec( &regex, argv[2], 0, NULL,0) ;
69 }
71 puts(apr_psprintf( context, "Time to run %d regex's %8lld\n",iters,end-now));
73 for (i=0;i<70;i++) {
75 }
76 now = apr_time_now();
77 for (i=0;i<iters;i++) {
79 }
81 puts(apr_psprintf( context, "Time to run %d hash (no find)'s %8lld\n",iters,end-now));
83 now = apr_time_now();
84 for (i=0;i<iters;i++) {
86 }
88 puts(apr_psprintf( context, "Time to run %d hash (find)'s %8lld\n",iters,end-now));
89
90 return 0;
91}
const ap_regex_t char * errbuf
Definition ap_regex.h:198
APR Miscellaneous library routines.
APR Hash Tables.
APR general purpose library routines.
APR memory allocation.
APR Strings library.
APR Time Library.
apr_md5_ctx_t * context
Definition util_md5.h:58
apr_redis_t * rc
Definition apr_redis.h:173
apr_size_t size
#define APR_SUCCESS
Definition apr_errno.h:225
apr_pool_t int argc
Definition apr_getopt.h:104
const apr_hash_t * h
Definition apr_hash.h:97
#define APR_HASH_KEY_STRING
Definition apr_hash.h:47
#define apr_pool_create(newpool, parent)
Definition apr_pools.h:322
const char char ** end
apr_int64_t apr_time_t
Definition apr_time.h:45
const char * argv[3]
return NULL
Definition mod_so.c:359
int i
Definition mod_so.c:347
int main(void)
Definition occhild.c:9
static apr_time_t now
Definition testtime.c:33
#define regex