Revision: 1357
http://vcs.pcre.org/viewvc?view=rev&revision=1357
Author: ph10
Date: 2013-08-27 16:49:16 +0100 (Tue, 27 Aug 2013)
Log Message:
-----------
Add -T and -TM to pcretest.
Modified Paths:
--------------
code/trunk/ChangeLog
code/trunk/doc/pcretest.1
code/trunk/pcretest.c
Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog 2013-08-15 17:46:58 UTC (rev 1356)
+++ code/trunk/ChangeLog 2013-08-27 15:49:16 UTC (rev 1357)
@@ -53,7 +53,7 @@
leading to a segfault or an incorrect match result.
10. A conditional group with an assertion condition could lead to PCRE
- recording an incorrect first data item for a match if no other firse data
+ recording an incorrect first data item for a match if no other first data
item was recorded. For example, the pattern (?(?=ab)ab) recorded "a" as a
first data item, and therefore matched "ca" after "c" instead of at the
start.
@@ -63,6 +63,8 @@
12. The source of pcregrep now includes z/OS-specific code so that it can be
compiled for z/OS as part of the special z/OS distribution.
+
+13. Added the -T and -TM options to pcretest.
Version 8.33 28-May-2013
Modified: code/trunk/doc/pcretest.1
===================================================================
--- code/trunk/doc/pcretest.1 2013-08-15 17:46:58 UTC (rev 1356)
+++ code/trunk/doc/pcretest.1 2013-08-27 15:49:16 UTC (rev 1357)
@@ -1,4 +1,4 @@
-.TH PCRETEST 1 "26 April 2013" "PCRE 8.33"
+.TH PCRETEST 1 "27 August 2013" "PCRE 8.34"
.SH NAME
pcretest - a program for testing Perl-compatible regular expressions.
.SH SYNOPSIS
@@ -216,17 +216,21 @@
should never be studied (see the \fB/S\fP pattern modifier below).
.TP 10
\fB-t\fP
-Run each compile, study, and match many times with a timer, and output
-resulting time per compile or match (in milliseconds). Do not set \fB-m\fP with
-\fB-t\fP, because you will then get the size output a zillion times, and the
-timing will be distorted. You can control the number of iterations that are
-used for timing by following \fB-t\fP with a number (as a separate item on the
-command line). For example, "-t 1000" would iterate 1000 times. The default is
-to iterate 500000 times.
+Run each compile, study, and match many times with a timer, and output the
+resulting times per compile, study, or match (in milliseconds). Do not set
+\fB-m\fP with \fB-t\fP, because you will then get the size output a zillion
+times, and the timing will be distorted. You can control the number of
+iterations that are used for timing by following \fB-t\fP with a number (as a
+separate item on the command line). For example, "-t 1000" iterates 1000 times.
+The default is to iterate 500000 times.
.TP 10
\fB-tm\fP
This is like \fB-t\fP except that it times only the matching phase, not the
compile or study phases.
+.TP 10
+\fB-T\fp \fB-TM\fP
+These behave like \fB-t\fP and \fB-tm\fP, but in addition, at the end of a run,
+the total times for all compiles, studies, and matches are output.
.
.
.SH DESCRIPTION
@@ -1094,6 +1098,6 @@
.rs
.sp
.nf
-Last updated: 26 April 2013
+Last updated: 27 August 2013
Copyright (c) 1997-2013 University of Cambridge.
.fi
Modified: code/trunk/pcretest.c
===================================================================
--- code/trunk/pcretest.c 2013-08-15 17:46:58 UTC (rev 1356)
+++ code/trunk/pcretest.c 2013-08-27 15:49:16 UTC (rev 1357)
@@ -2913,6 +2913,8 @@
printf(" -t <n> time compilation and execution, repeating <n> times\n");
printf(" -tm time execution (matching) only\n");
printf(" -tm <n> time execution (matching) only, repeating <n> times\n");
+printf(" -T same as -t, but show total times at the end\n");
+printf(" -TM same as -tm, but show total time at the end\n");
}
@@ -2935,6 +2937,7 @@
int op = 1;
int timeit = 0;
int timeitm = 0;
+int showtotaltimes = 0;
int showinfo = 0;
int showstore = 0;
int force_study = -1;
@@ -2951,6 +2954,9 @@
int stack_size;
pcre_uint8 *dbuffer = NULL;
size_t dbuffer_size = 1u << 14;
+clock_t total_compile_time = 0;
+clock_t total_study_time = 0;
+clock_t total_match_time = 0;
#if !defined NOPOSIX
int posix = 0;
@@ -3083,10 +3089,12 @@
op++;
argc--;
}
- else if (strcmp(arg, "-t") == 0 || strcmp(arg, "-tm") == 0)
+ else if (strcmp(arg, "-t") == 0 || strcmp(arg, "-tm") == 0 ||
+ strcmp(arg, "-T") == 0 || strcmp(arg, "-TM") == 0)
{
+ int temp;
int both = arg[2] == 0;
- int temp;
+ showtotaltimes = arg[1] == 'T';
if (argc > 2 && (temp = get_value((pcre_uint8 *)argv[op+1], &endptr),
*endptr == 0))
{
@@ -3875,7 +3883,7 @@
PCRE_COMPILE(re, p, options, &error, &erroroffset, tables);
if (re != NULL) free(re);
}
- time_taken = clock() - start_time;
+ total_compile_time += (time_taken = clock() - start_time);
fprintf(outfile, "Compile time %.4f milliseconds\n",
(((double)time_taken * 1000.0) / (double)timeit) /
(double)CLOCKS_PER_SEC);
@@ -3964,7 +3972,7 @@
{
PCRE_STUDY(extra, re, study_options, &error);
}
- time_taken = clock() - start_time;
+ total_study_time = (time_taken = clock() - start_time);
if (extra != NULL)
{
PCRE_FREE_STUDY(extra);
@@ -4984,7 +4992,7 @@
PCRE_EXEC(count, re, extra, bptr, len, start_offset,
(options | g_notempty), use_offsets, use_size_offsets);
}
- time_taken = clock() - start_time;
+ total_match_time += (time_taken = clock() - start_time);
fprintf(outfile, "Execute time %.4f milliseconds\n",
(((double)time_taken * 1000.0) / (double)timeitm) /
(double)CLOCKS_PER_SEC);
@@ -5494,6 +5502,23 @@
if (infile == stdin) fprintf(outfile, "\n");
+if (showtotaltimes)
+ {
+ fprintf(outfile, "--------------------------------------\n");
+ if (timeit > 0)
+ {
+ fprintf(outfile, "Total compile time %.4f milliseconds\n",
+ (((double)total_compile_time * 1000.0) / (double)timeit) /
+ (double)CLOCKS_PER_SEC);
+ fprintf(outfile, "Total study time %.4f milliseconds\n",
+ (((double)total_study_time * 1000.0) / (double)timeit) /
+ (double)CLOCKS_PER_SEC);
+ }
+ fprintf(outfile, "Total execute time %.4f milliseconds\n",
+ (((double)total_match_time * 1000.0) / (double)timeitm) /
+ (double)CLOCKS_PER_SEC);
+ }
+
EXIT:
if (infile != NULL && infile != stdin) fclose(infile);