diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-05-27 23:36:54 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-05-27 23:36:54 +0000 |
commit | d35edb4f61af98c575ed6ba0cf0e2c4ebe38bfe0 (patch) | |
tree | 1430dffd9a11e46c81e9627471e0676dd8d9012b | |
parent | 08561388cf181dc3eed416a0aeb85c28c9f4cc0b (diff) | |
download | gnunet-d35edb4f61af98c575ed6ba0cf0e2c4ebe38bfe0.tar.gz gnunet-d35edb4f61af98c575ed6ba0cf0e2c4ebe38bfe0.zip |
- expand regex perf to show resulting DFA: evaluate simplification from r27315
-rw-r--r-- | src/regex/perf-regex.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/regex/perf-regex.c b/src/regex/perf-regex.c index 4e339d228..666b0b8d2 100644 --- a/src/regex/perf-regex.c +++ b/src/regex/perf-regex.c | |||
@@ -38,6 +38,40 @@ usage(void) | |||
38 | } | 38 | } |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * Iterator callback function. | ||
42 | * | ||
43 | * @param cls closure. | ||
44 | * @param key hash for current state. | ||
45 | * @param proof proof for current state. | ||
46 | * @param accepting GNUNET_YES if this is an accepting state, GNUNET_NO if not. | ||
47 | * @param num_edges number of edges leaving current state. | ||
48 | * @param edges edges leaving current state. | ||
49 | */ | ||
50 | static void | ||
51 | iter (void *cls, | ||
52 | const struct GNUNET_HashCode *key, | ||
53 | const char *proof, | ||
54 | int accepting, | ||
55 | unsigned int num_edges, | ||
56 | const struct GNUNET_REGEX_Edge *edges) | ||
57 | { | ||
58 | unsigned int i; | ||
59 | |||
60 | printf ("%s: %s\n", GNUNET_h2s (key), accepting ? "ACCEPTING" : ""); | ||
61 | printf (" proof: %s\n", proof); | ||
62 | for (i = 0; i < num_edges; i++) | ||
63 | { | ||
64 | printf (" %s: %s\n", edges[i].label, GNUNET_h2s (&edges[i].destination)); | ||
65 | } | ||
66 | } | ||
67 | |||
68 | static void | ||
69 | print_dfa (struct GNUNET_REGEX_Automaton* dfa) | ||
70 | { | ||
71 | GNUNET_REGEX_iterate_all_edges (dfa, iter, NULL); | ||
72 | } | ||
73 | |||
74 | /** | ||
41 | * The main function of the regex performace test. | 75 | * The main function of the regex performace test. |
42 | * | 76 | * |
43 | * Read a set of regex from a file, combine them and create a DFA from the | 77 | * Read a set of regex from a file, combine them and create a DFA from the |
@@ -81,6 +115,7 @@ main (int argc, char *const *argv) | |||
81 | 115 | ||
82 | compression = atoi (argv[2]); | 116 | compression = atoi (argv[2]); |
83 | dfa = GNUNET_REGEX_construct_dfa (regex, size, compression); | 117 | dfa = GNUNET_REGEX_construct_dfa (regex, size, compression); |
118 | print_dfa (dfa); | ||
84 | GNUNET_REGEX_automaton_destroy (dfa); | 119 | GNUNET_REGEX_automaton_destroy (dfa); |
85 | GNUNET_free (buffer); | 120 | GNUNET_free (buffer); |
86 | GNUNET_REGEX_free_from_file (regexes); | 121 | GNUNET_REGEX_free_from_file (regexes); |