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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include "apr_strings.h"
19 #include "apr_pools.h"
20 #include "apr_general.h"
28 int main( int argc, char** argv) {
40 fprintf(stderr, "Usage %s match string #iterations\n",argv[0]);
43 iters = atoi( argv[3]);
46 atexit(apr_terminate);
47 if (apr_pool_create(&context, NULL) != APR_SUCCESS) {
48 fprintf(stderr, "Something went wrong\n");
51 rc = regcomp( ®ex, argv[1], REG_EXTENDED|REG_NOSUB);
56 regerror(rc, ®ex,errbuf,2000);
57 fprintf(stderr,"Couldn't compile regex ;(\n%s\n ",errbuf);
60 if ( regexec( ®ex, argv[2], 0, NULL,0) == 0 ) {
61 fprintf(stderr,"Match\n");
64 fprintf(stderr,"No Match\n");
67 for (i=0;i<iters;i++) {
68 regexec( ®ex, argv[2], 0, NULL,0) ;
71 puts(apr_psprintf( context, "Time to run %d regex's %8lld\n",iters,end-now));
72 h = apr_hash_make( context);
74 apr_hash_set(h,apr_psprintf(context, "%dkey",i),APR_HASH_KEY_STRING,"1");
77 for (i=0;i<iters;i++) {
78 apr_hash_get( h, argv[2], APR_HASH_KEY_STRING);
81 puts(apr_psprintf( context, "Time to run %d hash (no find)'s %8lld\n",iters,end-now));
82 apr_hash_set(h, argv[2],APR_HASH_KEY_STRING,"1");
84 for (i=0;i<iters;i++) {
85 apr_hash_get( h, argv[2], APR_HASH_KEY_STRING);
88 puts(apr_psprintf( context, "Time to run %d hash (find)'s %8lld\n",iters,end-now));