<commit_before>#include <Args.h>
#include <libs/include/Socket.h>
#include <libs/include/Timer.h>
#include <libs/include/TSCTimer.h>
#include <inttypes.h>
#include <iostream>
#include <stdio.h>
#include <unistd.h>

#ifndef PRIu64
#define PRIu64 "ull"
#endif

#define TSC_MHZ 3000

int main(int argc, char *argv[]) {

  Args opts(argc, argv);

  uint64_t tx_total = 0;
  uint64_t tx = 0;
  uint64_t txp = 0;
  const int B1M = 1000000;

  Socket::Endpoint local("0.0.0.0", 0);
  Socket::Endpoint remote(opts.dest_ip.c_str(), opts.port);
  UDPClient udptx(local, remote);
  udptx.buflen(opts.buflen);
  udptx.setbuffers(4000000, 4000000);
  udptx.printbuffers();

  Timer rate_timer, pkt_rate;
  TSCTimer report_timer;
  TSCTimer pkt_rate_timer;

  uint32_t seqno = 1;
  uint32_t txremain = 0;
  printf("TX: %d pps specified\n", opts.txpps);
  for (;;) {
    char buffer[10000];
    if (txremain) {
      *((uint32_t*)buffer) = seqno;
      auto txtmp = udptx.send(buffer, opts.buflen);
      seqno++;

      if (txtmp > 0) {
        txp++;
        tx += txtmp;
        txremain--;
      }
    } else {
       usleep(1);
    }

    if (pkt_rate_timer.timetsc() >= 10000UL * TSC_MHZ) {
      auto usecs = pkt_rate.timeus();
      txremain = usecs * opts.txpps / 1000000;
      pkt_rate_timer.now();
      pkt_rate.now();
    }

    if (report_timer.timetsc() >= 1000000UL * TSC_MHZ) {
      auto usecs = rate_timer.timeus();
      tx_total += tx;
      //printf("Txremain: %u\n", txremain);
      printf("Tx rate: %.2f Mbps, %.0f pps, tx %" PRIu64 " MB (total: %" PRIu64
             " MB) %" PRIu64 " usecs\n",
             tx * 8.0 / usecs,
             txp * 1000000.0 / usecs,
             tx / B1M,<commit_msg>remove pps calculations for tx<commit_after>#include <Args.h>
#include <libs/include/Socket.h>
#include <libs/include/Timer.h>
#include <libs/include/TSCTimer.h>
#include <inttypes.h>
#include <iostream>
#include <stdio.h>
#include <unistd.h>

#ifndef PRIu64
#define PRIu64 "ull"
#endif

#define TSC_MHZ 3000

int main(int argc, char *argv[]) {

  Args opts(argc, argv);

  uint64_t tx_total = 0;
  uint64_t tx = 0;
  uint64_t txp = 0;
  const int B1M = 1000000;

  Socket::Endpoint local("0.0.0.0", 0);
  Socket::Endpoint remote(opts.dest_ip.c_str(), opts.port);
  UDPClient udptx(local, remote);
  udptx.buflen(opts.buflen);
  udptx.setbuffers(4000000, 4000000);
  udptx.printbuffers();

  Timer rate_timer;
  TSCTimer report_timer;
  TSCTimer pkt_rate_timer;

  uint32_t seqno = 1;
  //Timer pkt_rate;
  //uint32_t txremain = 0;
  //printf("TX: %d pps specified\n", opts.txpps);
  for (;;) {
    char buffer[10000];
    *((uint32_t*)buffer) = seqno;
    auto txtmp = udptx.send(buffer, opts.buflen);
    seqno++;

    if (txtmp > 0) {
      txp++;
      tx += txtmp;
      //txremain--;
    }

#if 0
    if (pkt_rate_timer.timetsc() >= 10000UL * TSC_MHZ) {
      auto usecs = pkt_rate.timeus();
      txremain = usecs * opts.txpps / 1000000;
      pkt_rate_timer.now();
      pkt_rate.now();
    }
#endif

    if (report_timer.timetsc() >= 1000000UL * TSC_MHZ) {
      auto usecs = rate_timer.timeus();
      tx_total += tx;
      printf("Tx rate: %.2f Mbps, %.0f pps, tx %" PRIu64 " MB (total: %" PRIu64
             " MB) %" PRIu64 " usecs\n",
             tx * 8.0 / usecs,
             txp * 1000000.0 / usecs,
             tx / B1M,
{'fraction_non_alphanumeric': 0.15338704864219635, 'fraction_numerical': 0.057893166219039095, 'mean_word_length': 2.6997792494481234, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2302510', 'n_tokens_mistral': 1527, 'n_tokens_neox': 1362, 'n_words': 290}