#include #include #include #include #include "lf_ring_buffer.h" #define BUFFER_LEN 65000 //static rb_data_t data[BUFFER_LEN][RB_DATA_LEN]; static int64_t time_diff(struct timespec *t0, struct timespec *t1) { return ((t1->tv_sec * 1000000000) + t1->tv_nsec) - ((t0->tv_sec * 1000000000) + t0->tv_nsec); } /* static void print_now(char* s) { fprintf(stdout,s); fflush(stdout); } */ static void report( char* op, int n, uint64_t dt, int redo ) { fprintf(stdout,"\t%9d %s operations in %4d [ms] => %7d [us] => %10d [ns]\t >>> %6d [ns/op]\t%4d redone operations\n", n, op, (int)(dt/1000000), (int)(dt/1000), (int)dt, (int)(dt/n), redo ); } struct thread_params { lf_ring_buffer_t *ring; int n; int flags; }; /* static void feed_data( int n){ int i; for(i=0; in, sequential_writes( params->ring, params->n, params->flags ) ); sequential_writes( params->ring, params->n, params->flags ); return NULL; } void* reader_thread( void* param ) { struct thread_params *params = (struct thread_params*)param; //report( "read ", params->n, sequential_reads( params->ring, params->n, params->flags ) ); sequential_reads( params->ring, params->n, params->flags ); return NULL; } static void parallel_op( int op, int nt, lf_ring_buffer_t *ring, int n, int flags ) { int i; pthread_t *threads = malloc( sizeof(pthread_t)*nt); struct thread_params *params = malloc( sizeof(struct thread_params)*nt); for(i=0; i