|
@ -103,26 +103,26 @@ static void run_transop_benchmark(const char *op_name, n2n_trans_op_t *op_fn, ui |
|
|
n2n_common_t cmn; |
|
|
n2n_common_t cmn; |
|
|
n2n_PACKET_t pkt; |
|
|
n2n_PACKET_t pkt; |
|
|
n2n_mac_t mac_buf; |
|
|
n2n_mac_t mac_buf; |
|
|
|
|
|
const int target_sec = 3; |
|
|
struct timeval t1; |
|
|
struct timeval t1; |
|
|
struct timeval t2; |
|
|
struct timeval t2; |
|
|
|
|
|
|
|
|
size_t i; |
|
|
|
|
|
size_t n; |
|
|
|
|
|
size_t idx; |
|
|
size_t idx; |
|
|
size_t rem; |
|
|
size_t rem; |
|
|
ssize_t nw; |
|
|
ssize_t nw; |
|
|
ssize_t tdiff; |
|
|
ssize_t target_usec = target_sec * 1e6; |
|
|
|
|
|
ssize_t tdiff = 0; // microseconds
|
|
|
|
|
|
size_t num_packets = 0; |
|
|
|
|
|
|
|
|
n=10000; |
|
|
printf("Run [%s] for %us (%u bytes): ", op_name, target_sec, (unsigned int)sizeof(PKT_CONTENT)); |
|
|
|
|
|
fflush(stdout); |
|
|
|
|
|
|
|
|
memset(mac_buf, 0, sizeof(mac_buf)); |
|
|
memset(mac_buf, 0, sizeof(mac_buf)); |
|
|
gettimeofday( &t1, NULL ); |
|
|
gettimeofday( &t1, NULL ); |
|
|
for(i=0; i<n; ++i) |
|
|
|
|
|
{ |
|
|
while(tdiff < target_usec) { |
|
|
nw = do_encode_packet( pktbuf, N2N_PKT_BUF_SIZE, c); |
|
|
nw = do_encode_packet( pktbuf, N2N_PKT_BUF_SIZE, c); |
|
|
|
|
|
|
|
|
nw += op_fn->fwd( op_fn, |
|
|
nw += op_fn->fwd(op_fn, |
|
|
pktbuf+nw, N2N_PKT_BUF_SIZE-nw, |
|
|
pktbuf+nw, N2N_PKT_BUF_SIZE-nw, |
|
|
PKT_CONTENT, sizeof(PKT_CONTENT), mac_buf); |
|
|
PKT_CONTENT, sizeof(PKT_CONTENT), mac_buf); |
|
|
|
|
|
|
|
@ -132,21 +132,15 @@ static void run_transop_benchmark(const char *op_name, n2n_trans_op_t *op_fn, ui |
|
|
decode_common( &cmn, pktbuf, &rem, &idx); |
|
|
decode_common( &cmn, pktbuf, &rem, &idx); |
|
|
decode_PACKET( &pkt, &cmn, pktbuf, &rem, &idx ); |
|
|
decode_PACKET( &pkt, &cmn, pktbuf, &rem, &idx ); |
|
|
|
|
|
|
|
|
if ( 0 == (i%(n/10)) ) |
|
|
|
|
|
{ |
|
|
|
|
|
fprintf(stderr,"."); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
gettimeofday( &t2, NULL ); |
|
|
gettimeofday( &t2, NULL ); |
|
|
|
|
|
|
|
|
tdiff = ((t2.tv_sec - t1.tv_sec) * 1000000) + (t2.tv_usec - t1.tv_usec); |
|
|
tdiff = ((t2.tv_sec - t1.tv_sec) * 1000000) + (t2.tv_usec - t1.tv_usec); |
|
|
|
|
|
num_packets++; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
float mpps = num_packets / (tdiff / 1e6) / 1e6; |
|
|
|
|
|
|
|
|
fprintf( stderr, "\n[%s] %u times: (%u -> %u nsec each) %u.%06u -> %u.%06u.\n", |
|
|
printf("\t%12u packets\t%8.1f Kpps\t%8.1f MB/s\n", |
|
|
op_name, |
|
|
(unsigned int)num_packets, mpps * 1e3, mpps * sizeof(PKT_CONTENT)); |
|
|
(unsigned int)i, (unsigned int)tdiff, |
|
|
|
|
|
(unsigned int)((tdiff *1000)/i), |
|
|
|
|
|
(uint32_t)t1.tv_sec, (uint32_t)t1.tv_usec, |
|
|
|
|
|
(uint32_t)t2.tv_sec, (uint32_t)t2.tv_usec ); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static ssize_t do_encode_packet( uint8_t * pktbuf, size_t bufsize, const n2n_community_t c ) |
|
|
static ssize_t do_encode_packet( uint8_t * pktbuf, size_t bufsize, const n2n_community_t c ) |
|
|