Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Unified Diff: third_party/re2/re2/testing/regexp_benchmark.cc

Issue 1530113002: Revert of Update re2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/re2/re2/testing/re2_test.cc ('k') | third_party/re2/re2/testing/regexp_generator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/re2/re2/testing/regexp_benchmark.cc
diff --git a/third_party/re2/re2/testing/regexp_benchmark.cc b/third_party/re2/re2/testing/regexp_benchmark.cc
index 6c198583014fb8ff346710126781704ef2e4e283..ca7627f5d59b17d90a691bae770cc062ed99285c 100644
--- a/third_party/re2/re2/testing/regexp_benchmark.cc
+++ b/third_party/re2/re2/testing/regexp_benchmark.cc
@@ -135,15 +135,13 @@
// Generate random text that won't contain the search string,
// to test worst-case search behavior.
void MakeText(string* text, int nbytes) {
- srand(1);
text->resize(nbytes);
+ srand(0);
for (int i = 0; i < nbytes; i++) {
- // Generate a one-byte rune that isn't a control character (e.g. '\n').
- // Clipping to 0x20 introduces some bias, but we don't need uniformity.
- int byte = rand() & 0x7F;
- if (byte < 0x20)
- byte = 0x20;
- (*text)[i] = byte;
+ if (!rand()%30)
+ (*text)[i] = '\n';
+ else
+ (*text)[i] = rand()%(0x7E + 1 - 0x20)+0x20;
}
}
@@ -265,7 +263,6 @@
BENCHMARK_RANGE(Search_BigFixed_CachedRE2, 8, 1<<20)->ThreadRange(1, NumCPUs());
// Benchmark: FindAndConsume
-
void FindAndConsume(int iters, int nbytes) {
StopBenchmarkTiming();
string s;
@@ -287,11 +284,9 @@
// Benchmark: successful anchored search.
void SearchSuccess(int iters, int nbytes, const char* regexp, SearchImpl* search) {
- StopBenchmarkTiming();
string s;
MakeText(&s, nbytes);
BenchmarkMemoryUsage();
- StartBenchmarkTiming();
search(iters, regexp, s, Prog::kAnchored, true);
SetBenchmarkBytesProcessed(static_cast<int64>(iters)*nbytes);
}
@@ -349,9 +344,11 @@
// Benchmark: use regexp to find phone number.
void SearchDigits(int iters, SearchImpl* search) {
- StringPiece s("650-253-0001");
+ const char *text = "650-253-0001";
+ int len = strlen(text);
BenchmarkMemoryUsage();
- search(iters, "([0-9]+)-([0-9]+)-([0-9]+)", s, Prog::kAnchored, true);
+ search(iters, "([0-9]+)-([0-9]+)-([0-9]+)",
+ StringPiece(text, len), Prog::kAnchored, true);
SetBenchmarkItemsProcessed(iters);
}
@@ -688,6 +685,7 @@
BENCHMARK(BM_Regexp_SimplifyCompile)->ThreadRange(1, NumCPUs());
BENCHMARK(BM_Regexp_NullWalk)->ThreadRange(1, NumCPUs());
BENCHMARK(BM_RE2_Compile)->ThreadRange(1, NumCPUs());
+
// Makes text of size nbytes, then calls run to search
// the text for regexp iters times.
« no previous file with comments | « third_party/re2/re2/testing/re2_test.cc ('k') | third_party/re2/re2/testing/regexp_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698