summaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorPhilip Balister <balister@moose.(none)>2010-05-12 14:11:10 -0400
committerPhilip Balister <balister@moose.(none)>2010-05-12 14:11:10 -0400
commit9251c115b302b7b5773e2e16bbd7a7dfd6c18b74 (patch)
tree8c2decbb201258256a83434d0ac67b1034156a83 /host
parent019be7444989b977de9e94677bc259bad9eb6843 (diff)
downloaduhd-9251c115b302b7b5773e2e16bbd7a7dfd6c18b74.tar.gz
uhd-9251c115b302b7b5773e2e16bbd7a7dfd6c18b74.tar.bz2
uhd-9251c115b302b7b5773e2e16bbd7a7dfd6c18b74.zip
Add calculation for data trasnfer rates.
Diffstat (limited to 'host')
-rw-r--r--host/apps/omap_debug/usrp-e-crc-rw.c46
1 files changed, 43 insertions, 3 deletions
diff --git a/host/apps/omap_debug/usrp-e-crc-rw.c b/host/apps/omap_debug/usrp-e-crc-rw.c
index 1f23c8d54..f99654781 100644
--- a/host/apps/omap_debug/usrp-e-crc-rw.c
+++ b/host/apps/omap_debug/usrp-e-crc-rw.c
@@ -44,6 +44,8 @@ static void *read_thread(void *threadid)
int i;
unsigned long crc;
unsigned int rx_crc;
+ unsigned long bytes_transfered, elapsed_seconds;
+ struct timeval start_time, finish_time;
printf("Greetings from the reading thread!\n");
@@ -51,7 +53,10 @@ static void *read_thread(void *threadid)
rx_data = malloc(2048);
rx_pkt_cnt = 0;
-
+
+ bytes_transfered = 0;
+ gettimeofday(&start_time, NULL);
+
while (1) {
cnt = read(fp, rx_data, 2048);
@@ -81,7 +86,20 @@ static void *read_thread(void *threadid)
printf("CRC Error, sent: %d, rx: %d\n",
rx_crc, (crc & 0xFFFFFFFF));
}
-
+
+ bytes_transfered += rx_data->len;
+
+ if (bytes_transfered > (100 * 1000000)) {
+ gettimeofday(&finish_time, NULL);
+ elapsed_seconds = start_time.tv_sec - finish_time.tv_sec;
+
+ printf("RX data transfer rate = %f K Bps\n",
+ (float) bytes_transfered / (float) elapsed_seconds / 1000);
+
+
+ start_time = finish_time;
+ bytes_transfered = 0;
+ }
}
}
@@ -91,12 +109,16 @@ static void *write_thread(void *threadid)
int tx_len;
unsigned long crc;
struct usrp_transfer_frame *tx_data;
- struct pkt *p;
+ unsigned long bytes_transfered, elapsed_seconds;
+ struct timeval start_time, finish_time;
printf("Greetings from the write thread!\n");
tx_data = malloc(2048);
+ bytes_transfered = 0;
+ gettimeofday(&start_time, NULL);
+
while (1) {
tx_pkt_cnt++;
@@ -115,6 +137,8 @@ static void *write_thread(void *threadid)
}
tx_len = 2048 - sizeof(struct usrp_transfer_frame) - sizeof(int);
+ tx_data->len = tx_len + sizeof(int);
+
crc = 0xFFFFFFFF;
for (i = 0; i < tx_len; i++) {
tx_data->buf[i] = rand() & 0xFF;
@@ -128,6 +152,22 @@ static void *write_thread(void *threadid)
cnt = write(fp, tx_data, 2048);
if (cnt < 0)
printf("Error returned from write: %d\n", cnt);
+
+
+ bytes_transfered += tx_data->len;
+
+ if (bytes_transfered > (100 * 1000000)) {
+ gettimeofday(&finish_time, NULL);
+ elapsed_seconds = start_time.tv_sec - finish_time.tv_sec;
+
+ printf("TX data transfer rate = %f K Bps\n",
+ (float) bytes_transfered / (float) elapsed_seconds / 1000);
+
+
+ start_time = finish_time;
+ bytes_transfered = 0;
+ }
+
// sleep(1);
}
}