tests improved
This commit is contained in:
parent
7cab4db54a
commit
51daa79d39
|
@ -168,10 +168,11 @@ int radix_search(radix_holder_t t, record_t r) {
|
||||||
/*--------------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------------*/
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#define RULES_FILE "../data/routing-data"
|
#define RULES_FILE "../data/routing-data"
|
||||||
#define TEST_FILE "../data/test-data"
|
#define TEST_FILE "../data/test-data"
|
||||||
#define TEST_ROWS 6286
|
#define TEST_ROWS 39222 /*39222*/
|
||||||
#define READ_MODE "r"
|
#define READ_MODE "r"
|
||||||
|
|
||||||
int parse_line(FILE* f, record_t r) {
|
int parse_line(FILE* f, record_t r) {
|
||||||
|
@ -258,9 +259,12 @@ int load_tests(struct routing_record** ref) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (cnt = 0; cnt < TEST_ROWS; ++cnt)
|
for (cnt = 0; cnt < TEST_ROWS; ++cnt) {
|
||||||
if (!parse_line(f, &r[cnt]))
|
if (!parse_line(f, &r[cnt])) {
|
||||||
printf("test parse failed %d\n", cnt);
|
printf("WARNING test parse failed %d\n", cnt);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
*ref = r;
|
*ref = r;
|
||||||
|
@ -270,21 +274,36 @@ int load_tests(struct routing_record** ref) {
|
||||||
int fire_tests(radix_holder_t t, struct routing_record* r) {
|
int fire_tests(radix_holder_t t, struct routing_record* r) {
|
||||||
int row;
|
int row;
|
||||||
int wrong = TEST_ROWS;
|
int wrong = TEST_ROWS;
|
||||||
unsigned short ref_pop;
|
unsigned short ref_pop, ref_scope;
|
||||||
|
|
||||||
for (row = 0; row < TEST_ROWS; ++row, ++r) {
|
clock_t start, end;
|
||||||
ref_pop = r->_rule;
|
double lookup_time;
|
||||||
r->_rule = INVALID_RULE;
|
|
||||||
radix_search(t, r);
|
start = clock();
|
||||||
if ( ref_pop == r->_rule)
|
|
||||||
|
for (row = 0; row < TEST_ROWS; ++row) {
|
||||||
|
ref_pop = r[row]._rule;
|
||||||
|
ref_scope = r[row]._mask;
|
||||||
|
|
||||||
|
r[row]._rule = INVALID_RULE;
|
||||||
|
radix_search(t, &r[row]);
|
||||||
|
if (ref_pop == r[row]._rule && ref_scope == r[row]._mask) {
|
||||||
--wrong;
|
--wrong;
|
||||||
else
|
} else {
|
||||||
printf("ref: %d got: %d @ %d\n", ref_pop, r->_rule, row );
|
if (ref_pop != r[row]._rule)
|
||||||
|
printf("pop: %d got: %d @ %d\n", ref_pop, r[row]._rule, row );
|
||||||
|
if (ref_scope != r[row]._mask)
|
||||||
|
printf("scp: %d got: %d @ %d\n", ref_scope, r[row]._mask, row );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
end = clock();
|
||||||
|
lookup_time = ((double) (end - start)) / CLOCKS_PER_SEC * 1000;
|
||||||
|
|
||||||
|
printf("%d lookups in %f ms (%f microseconds per op)\n", TEST_ROWS, lookup_time, ((end - start)/(double)TEST_ROWS));
|
||||||
|
|
||||||
free(r);
|
free(r);
|
||||||
*/
|
|
||||||
return wrong;
|
return wrong;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue