From: Ben Pfaff Date: Wed, 26 May 2010 22:24:13 +0000 (-0700) Subject: tests: Speed up classifier test. X-Git-Tag: v1.0.1~25 X-Git-Url: http://git.cascardo.eti.br/?a=commitdiff_plain;h=70d3fbe7658b59bac65f8b4f2ba03602acf7f1c2;p=cascardo%2Fovs.git tests: Speed up classifier test. Many of the classifier tests take time exponential in the number of fields, because the existing compare_classifiers() iterates over 2^n_fields possibilities. This is very slow. This commit fixes the problem by only testing a fixed number of random possibilities instead of all of them. This makes it much, much faster. --- diff --git a/tests/test-classifier.c b/tests/test-classifier.c index a63b7cab3..57a1e2c2c 100644 --- a/tests/test-classifier.c +++ b/tests/test-classifier.c @@ -352,17 +352,18 @@ lookup_with_include_bits(const struct classifier *cls, static void compare_classifiers(struct classifier *cls, struct tcls *tcls) { + static const int confidence = 500; unsigned int i; assert(classifier_count(cls) == tcls->n_rules); assert(classifier_count_exact(cls) == tcls_count_exact(tcls)); - for (i = 0; i < N_FLOW_VALUES; i++) { + for (i = 0; i < confidence; i++) { struct cls_rule *cr0, *cr1; flow_t flow; unsigned int x; int include; - x = i; + x = rand () % N_FLOW_VALUES; flow.nw_src = nw_src_values[get_value(&x, N_NW_SRC_VALUES)]; flow.nw_dst = nw_dst_values[get_value(&x, N_NW_DST_VALUES)]; flow.tun_id = tun_id_values[get_value(&x, N_TUN_ID_VALUES)];