From: Ulya Trofimovich Date: Mon, 17 Jun 2019 09:27:07 +0000 (+0100) Subject: libre2c benchmark: print size of each regular expression and the number of capturing... X-Git-Tag: 1.2~59 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8f5bf0b2ecc1d34eb7089bf743b2cf0bc5cefa5f;p=re2c libre2c benchmark: print size of each regular expression and the number of capturing groups in it. --- diff --git a/lib/bench.cc b/lib/bench.cc index 343a3c49..c9d41376 100644 --- a/lib/bench.cc +++ b/lib/bench.cc @@ -152,13 +152,23 @@ static Result bench_re2(const char *regexp, std::vector &strings } #endif +static uint32_t groupcnt(const char *r) +{ + uint32_t cnt = 0; + for (; *r; ++r) { + if (*r == '(') ++cnt; + } + return cnt; +} + static void bench(const char *r, std::vector &ss, size_t n , int mask, int need) { assert(!ss.empty()); const char *s0 = ss[0].c_str(); - fprintf(stderr, "\nr: %.*s..., s: %.*s..., n: %lu\n", 30, r, 30, s0, n); + fprintf(stderr, "\nr: %.*s..., s: %.*s..., n: %lu, %lu chars, %u groups\n" + , 30, r, 30, s0, n, strlen(r), groupcnt(r)); std::vector rs;