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

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

Issue 1516543002: Update re2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated update instructions 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/compile_test.cc ('k') | third_party/re2/re2/testing/dump.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/re2/re2/testing/dfa_test.cc
diff --git a/third_party/re2/re2/testing/dfa_test.cc b/third_party/re2/re2/testing/dfa_test.cc
index 8e95ae4b7efb3a5825b72936ac16eff988dd26e0..e9c7befd6906d871bff780775317c8debe1a22a8 100644
--- a/third_party/re2/re2/testing/dfa_test.cc
+++ b/third_party/re2/re2/testing/dfa_test.cc
@@ -2,14 +2,16 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-#include "util/test.h"
#include "util/thread.h"
+#include "util/test.h"
#include "re2/prog.h"
#include "re2/re2.h"
#include "re2/regexp.h"
#include "re2/testing/regexp_generator.h"
#include "re2/testing/string_generator.h"
+static const bool UsingMallocCounter = false;
+
DECLARE_bool(re2_dfa_bail_when_slow);
DEFINE_int32(size, 8, "log2(number of DFA nodes)");
@@ -42,7 +44,7 @@ TEST(Multithreaded, BuildEntireDFA) {
// Check that single-threaded code works.
{
//LOG(INFO) << s;
- Regexp* re = Regexp::Parse(s.c_str(), Regexp::LikePerl, NULL);
+ Regexp* re = Regexp::Parse(s, Regexp::LikePerl, NULL);
CHECK(re);
Prog* prog = re->CompileToProg(0);
CHECK(prog);
@@ -57,7 +59,7 @@ TEST(Multithreaded, BuildEntireDFA) {
// Build the DFA simultaneously in a bunch of threads.
for (int i = 0; i < FLAGS_repeat; i++) {
- Regexp* re = Regexp::Parse(s.c_str(), Regexp::LikePerl, NULL);
+ Regexp* re = Regexp::Parse(s, Regexp::LikePerl, NULL);
CHECK(re);
Prog* prog = re->CompileToProg(0);
CHECK(prog);
@@ -92,14 +94,13 @@ TEST(SingleThreaded, BuildEntireDFA) {
s += "[ab]";
s += "b";
- //LOG(INFO) << s;
- Regexp* re = Regexp::Parse(s.c_str(), Regexp::LikePerl, NULL);
+ Regexp* re = Regexp::Parse(s, Regexp::LikePerl, NULL);
CHECK(re);
int max = 24;
for (int i = 17; i < max; i++) {
- int limit = 1<<i;
- int usage;
- //int progusage, dfamem;
+ int64 limit = 1<<i;
+ int64 usage;
+ //int64 progusage, dfamem;
{
testing::MallocCounter m(testing::MallocCounter::THIS_THREAD_ONLY);
Prog* prog = re->CompileToProg(limit);
@@ -113,10 +114,13 @@ TEST(SingleThreaded, BuildEntireDFA) {
}
if (!UsingMallocCounter)
continue;
- //LOG(INFO) << StringPrintf("Limit %d: prog used %d, DFA budget %d, total %d\n",
- // limit, progusage, dfamem, usage);
+ //LOG(INFO) << "limit " << limit << ", "
+ // << "prog usage " << progusage << ", "
+ // << "DFA budget " << dfamem << ", "
+ // << "total " << usage;
+ // Tolerate +/- 10%.
CHECK_GT(usage, limit*9/10);
- CHECK_LT(usage, limit + (16<<10)); // 16kB of slop okay
+ CHECK_LT(usage, limit*11/10);
}
re->Decref();
}
@@ -132,7 +136,7 @@ TEST(SingleThreaded, BuildEntireDFA) {
// position in the input, never reusing any states until it gets to the
// end of the string. This is the worst possible case for DFA execution.
static string DeBruijnString(int n) {
- CHECK_LT(n, 8*sizeof(int));
+ CHECK_LT(n, static_cast<int>(8*sizeof(int)));
CHECK_GT(n, 0);
vector<bool> did(1<<n);
@@ -221,13 +225,13 @@ TEST(SingleThreaded, SearchDFA) {
peak_usage = m.PeakHeapGrowth();
delete prog;
}
- re->Decref();
-
if (!UsingMallocCounter)
return;
- //LOG(INFO) << "usage " << usage << " " << peak_usage;
+ //LOG(INFO) << "usage " << usage << ", "
+ // << "peak usage " << peak_usage;
CHECK_LT(usage, 1<<n);
CHECK_LT(peak_usage, 1<<n);
+ re->Decref();
}
// Helper thread: searches for match, which should match,
« no previous file with comments | « third_party/re2/re2/testing/compile_test.cc ('k') | third_party/re2/re2/testing/dump.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698