*/
/**
- * @file regex/prof-regex.c
+ * @file src/regex/prof-regex.c
* @brief Test how long it takes to create a automaton from a string regex.
* @author Bartlomiej Polot
*/
#include <time.h>
#include "platform.h"
#include "gnunet_regex_lib.h"
+#include "regex_test_lib.h"
static const char *exe;
int
main (int argc, char *const *argv)
{
- FILE *f;
struct GNUNET_REGEX_Automaton* dfa;
- long size;
+ char **regexes;
+ char *buffer;
char *regex;
int compression;
+ long size;
+ GNUNET_log_setup ("perf-regex", "DEBUG", NULL);
exe = argv[0];
if (3 != argc)
{
usage();
return 1;
}
- f = fopen (argv[1], "r");
- if (NULL == f)
+ regexes = GNUNET_REGEX_read_from_file (argv[1]);
+
+ if (NULL == regexes)
{
- fprintf (stderr, "Can't open file %s\n", argv[1]);
usage();
return 2;
}
- fseek (f, 0, SEEK_END);
- size = ftell (f);
- fseek (f, 0, SEEK_SET);
- regex = GNUNET_malloc (size);
- if (fread (regex, sizeof(char), size, f) != size)
- {
- fprintf (stderr, "Can't read file %s\n", argv[1]);
- usage();
- return 3;
- }
+ buffer = GNUNET_REGEX_combine (regexes);
+
+ GNUNET_asprintf (®ex, "GNVPN-0001-PAD(%s)(0|1)*", buffer);
+ size = strlen (regex);
+
+ // fprintf (stderr, "Combined regex (%ld bytes):\n%s\n", size, regex);
+ // return 0;
+
compression = atoi (argv[2]);
dfa = GNUNET_REGEX_construct_dfa (regex, size, compression);
GNUNET_REGEX_automaton_destroy (dfa);
- GNUNET_free (regex);
+ GNUNET_free (buffer);
+ GNUNET_REGEX_free_from_file (regexes);
return 0;
}