MCPcopy Create free account
hub / github.com/axboe/liburing / show_buckets

Function show_buckets

examples/proxy.c:500–548  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

498}
499
500static void show_buckets(struct conn_dir *cd)
501{
502 unsigned long snd_total, rcv_total;
503 struct bucket_stat *rstat, *sstat;
504 int i;
505
506 if (!cd->rcv_bucket || !cd->snd_bucket)
507 return;
508
509 rstat = calloc(nr_bufs + 1, sizeof(struct bucket_stat));
510 sstat = calloc(nr_bufs + 1, sizeof(struct bucket_stat));
511
512 snd_total = rcv_total = 0;
513 for (i = 0; i <= nr_bufs; i++) {
514 snd_total += cd->snd_bucket[i];
515 sstat[i].nr_packets = i;
516 sstat[i].count = cd->snd_bucket[i];
517 rcv_total += cd->rcv_bucket[i];
518 rstat[i].nr_packets = i;
519 rstat[i].count = cd->rcv_bucket[i];
520 }
521
522 if (!snd_total && !rcv_total) {
523 free(sstat);
524 free(rstat);
525 }
526 if (snd_total)
527 qsort(sstat, nr_bufs, sizeof(struct bucket_stat), stat_cmp);
528 if (rcv_total)
529 qsort(rstat, nr_bufs, sizeof(struct bucket_stat), stat_cmp);
530
531 printf("\t Packets per recv/send:\n");
532 for (i = 0; i <= nr_bufs; i++) {
533 double snd_prc = 0.0, rcv_prc = 0.0;
534 if (!rstat[i].count && !sstat[i].count)
535 continue;
536 if (rstat[i].count)
537 rcv_prc = 100.0 * (rstat[i].count / (double) rcv_total);
538 if (sstat[i].count)
539 snd_prc = 100.0 * (sstat[i].count / (double) snd_total);
540 printf("\t bucket(%3d/%3d): rcv=%u (%.2f%%) snd=%u (%.2f%%)\n",
541 rstat[i].nr_packets, sstat[i].nr_packets,
542 rstat[i].count, rcv_prc,
543 sstat[i].count, snd_prc);
544 }
545
546 free(sstat);
547 free(rstat);
548}
549
550static void __show_stats(struct conn *c)
551{

Callers 1

__show_statsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected