Skip to content

Commit

Permalink
Merge pull request #204 from OpenVisualCloud/Test-rdma-performance
Browse files Browse the repository at this point in the history
Print throughput in sample apps
  • Loading branch information
Sakoram authored Sep 25, 2024
2 parents 04ba4b8 + 043ec8f commit acde674
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
32 changes: 18 additions & 14 deletions sdk/samples/recver_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,10 @@ int main(int argc, char** argv)
// uint32_t frm_size = width * height * 3 / 2; //TODO:assume it's NV12
uint32_t frm_size = getFrameSize(PIX_FMT_YUV422P_10BIT_LE, width, height, false);

const uint32_t fps_interval = 30;
const uint32_t stat_interval = 10;
double fps = 0.0;
double throughput_MB = 0;
double stat_period_s = 0;
void *ptr = NULL;
int timeout = -1;
bool first_frame = true;
Expand Down Expand Up @@ -382,22 +384,9 @@ int main(int argc, char** argv)
ptr += sizeof(frame_count);
ts_send = *(struct timespec *)ptr;

if (frame_count % fps_interval == 0) {
/* calculate FPS */
clock_gettime(CLOCK_REALTIME, &ts_end);

fps = 1e9 * (ts_end.tv_sec - ts_begin.tv_sec);
fps += (ts_end.tv_nsec - ts_begin.tv_nsec);
fps /= 1e9;
fps = (double)fps_interval / fps;

clock_gettime(CLOCK_REALTIME, &ts_begin);
}

latency = 1000.0 * (ts_recv.tv_sec - ts_send.tv_sec);
latency += (ts_recv.tv_nsec - ts_send.tv_nsec) / 1000000.0;

printf("RX frames: [%u], latency: %0.1f ms, FPS: %0.3f\n", frame_count, latency, fps);
}
} else { //TODO: rtsp receiver side test code
if (dump_fp) {
Expand All @@ -406,12 +395,27 @@ int main(int argc, char** argv)
printf("RX package number:%d seq_num: %d, timestamp: %u, RX H264 NALU: %ld\n", frame_count, buf->metadata.seq_num, buf->metadata.timestamp, buf->len);
}

if (frame_count % stat_interval == 0) {
/* calculate FPS */
clock_gettime(CLOCK_REALTIME, &ts_end);

stat_period_s = (ts_end.tv_sec - ts_begin.tv_sec);
stat_period_s += (ts_end.tv_nsec - ts_begin.tv_nsec) / 1e9;
fps = stat_interval / stat_period_s;
throughput_MB = fps * frm_size / 1000000;

clock_gettime(CLOCK_REALTIME, &ts_begin);
}
printf("RX frames: [%u], latency: %0.1f ms, FPS: %0.3f\n", frame_count, latency, fps);
printf("Throughput: %.2lf MB/s, %.2lf Gb/s \n", throughput_MB, throughput_MB * 8 / 1000);

frame_count++;

/* enqueue buffer */
if (mcm_enqueue_buffer(dp_ctx, buf) != 0) {
break;
}
printf("\n");
}

/* Clean up */
Expand Down
16 changes: 10 additions & 6 deletions sdk/samples/sender_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,10 @@ int main(int argc, char** argv)

FILE* input_fp = NULL;
uint32_t frame_count = 0;
const uint32_t fps_interval = 30;
const uint32_t stat_interval = 10;
double fps = 0.0;
double throughput_MB = 0;
double stat_period_s = 0;
struct timespec ts_begin = {}, ts_end = {};
struct timespec ts_frame_begin = {}, ts_frame_end = {};

Expand Down Expand Up @@ -422,19 +424,20 @@ int main(int argc, char** argv)
break;
}

if (frame_count % fps_interval == 0) {
if (frame_count % stat_interval == 0) {
/* calculate FPS */
clock_gettime(CLOCK_REALTIME, &ts_end);

fps = 1e9 * (ts_end.tv_sec - ts_begin.tv_sec);
fps += (ts_end.tv_nsec - ts_begin.tv_nsec);
fps /= 1e9;
fps = (double)fps_interval / fps;
stat_period_s = (ts_end.tv_sec - ts_begin.tv_sec);
stat_period_s += (ts_end.tv_nsec - ts_begin.tv_nsec) / 1e9;
fps = stat_interval / stat_period_s;
throughput_MB = fps * frame_size / 1000000;

clock_gettime(CLOCK_REALTIME, &ts_begin);
}

printf("TX frames: [%d], FPS: %0.2f [%0.2f]\n", frame_count, fps, vid_fps);
printf("Throughput: %.2lf MB/s, %.2lf Gb/s \n", throughput_MB, throughput_MB * 8 / 1000);

frame_count++;

Expand All @@ -450,6 +453,7 @@ int main(int argc, char** argv)
printf("pacing: %d\n", pacing);
printf("spend: %d\n", spend);

printf("\n");
}

sleep(2);
Expand Down

0 comments on commit acde674

Please sign in to comment.