You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

55 lines
2.1 KiB

// tests/test_etcp_stress.c - Minimal stress routing test
#include "routing.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define NUM_ROUTES 500
#define NUM_LOOKUPS 5000
int main(void) {
printf("ETCP Stress Test: Routing Table Performance\n");
printf("═════════════════════════════════════════════\n\n");
struct routing_table* rt = routing_table_create();
if (!rt) {
printf("Error: Failed to create routing table\n");
return 1;
}
clock_t start = clock();
// Insert routes
for (int i = 0; i < NUM_ROUTES; i++) {
struct route_entry route = {
.network = (10 << 24) | (i << 8),
.prefix_length = 24,
.type = 0,
.flags = 1
};
routing_table_insert(rt, &route);
}
clock_t insert_done = clock();
double insert_time = ((double)(insert_done - start)) / CLOCKS_PER_SEC;
printf("✓ Inserted %d routes in %.3f seconds\n", NUM_ROUTES, insert_time);
// Perform lookups
for (int i = 0; i < NUM_LOOKUPS; i++) {
struct route_entry found;
uint32_t ip = (10 << 24) | ((i % NUM_ROUTES) << 8) | 100;
routing_table_lookup(rt, ip, &found);
}
clock_t lookup_done = clock();
double lookup_time = ((double)(lookup_done - insert_done)) / CLOCKS_PER_SEC;
printf("✓ Performed %d lookups in %.3f seconds\n", NUM_LOOKUPS, lookup_time);
routing_table_destroy(rt);
printf("\n╔═══════════════════════════════════════════════════════════════╗\n");
printf("║ PERFORMANCE TEST PASSED ║\n");
printf("╚═══════════════════════════════════════════════════════════════╝\n");
return 0;
}