Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 96c416a in mainline


Ignore:
Timestamp:
2017-12-22T12:19:02Z (4 years ago)
Author:
Petr Mánek <petr.manek@…>
Branches:
lfn, master
Children:
b10a434
Parents:
b7b7898
Message:

usbdiag: measure test duration

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbdiag/tests.c

    rb7b7898 r96c416a  
    3737#include <str_error.h>
    3838#include <usb/debug.h>
     39#include <time.h>
    3940#include "device.h"
    4041#include "tests.h"
     
    4243#define NAME "usbdiag"
    4344
    44 static int burst_in_test(usb_pipe_t *pipe, int cycles, size_t size)
     45static int burst_in_test(usb_pipe_t *pipe, int cycles, size_t size, unsigned long *duration)
    4546{
    4647        if (!pipe)
     
    5455
    5556        usb_log_info("Performing %s IN burst test.", usb_str_transfer_type(pipe->desc.transfer_type));
     57
    5658        int rc = EOK;
     59        struct timeval start_time;
     60        gettimeofday(&start_time, NULL);
     61
    5762        for (int i = 0; i < cycles; ++i) {
    5863                // Read device's response.
     
    7883                        break;
    7984        }
    80         usb_log_info("Burst test on %s IN endpoint completed.", usb_str_transfer_type(pipe->desc.transfer_type));
     85
     86        struct timeval final_time;
     87        gettimeofday(&final_time, NULL);
     88        unsigned long in_duration = ((final_time.tv_usec - start_time.tv_usec) / 1000) +
     89            ((final_time.tv_sec - start_time.tv_sec) * 1000);
     90
     91        usb_log_info("Burst test on %s IN endpoint completed in %lu ms.", usb_str_transfer_type(pipe->desc.transfer_type), in_duration);
    8192
    8293        free(buffer);
     94        if (duration)
     95                *duration = in_duration;
     96
    8397        return rc;
    8498}
    8599
    86 static int burst_out_test(usb_pipe_t *pipe, int cycles, size_t size)
     100static int burst_out_test(usb_pipe_t *pipe, int cycles, size_t size, unsigned long *duration)
    87101{
    88102        if (!pipe)
     
    98112
    99113        usb_log_info("Performing %s OUT burst test.", usb_str_transfer_type(pipe->desc.transfer_type));
     114
    100115        int rc = EOK;
     116        struct timeval start_time;
     117        gettimeofday(&start_time, NULL);
     118
    101119        for (int i = 0; i < cycles; ++i) {
    102120                // Write buffer to device.
     
    106124                }
    107125        }
    108         usb_log_info("Burst test on %s OUT endpoint completed.", usb_str_transfer_type(pipe->desc.transfer_type));
     126
     127        struct timeval final_time;
     128        gettimeofday(&final_time, NULL);
     129        unsigned long in_duration = ((final_time.tv_usec - start_time.tv_usec) / 1000) +
     130            ((final_time.tv_sec - start_time.tv_sec) * 1000);
     131
     132        usb_log_info("Burst test on %s OUT endpoint completed in %ld ms.", usb_str_transfer_type(pipe->desc.transfer_type), in_duration);
    109133
    110134        free(buffer);
     135        if (duration)
     136                *duration = in_duration;
     137
    111138        return rc;
    112139}
     
    118145                return EBADMEM;
    119146
    120         return burst_in_test(dev->intr_in, cycles, size);
     147        // FIXME: report duration
     148        return burst_in_test(dev->intr_in, cycles, size, NULL);
    121149}
    122150
     
    127155                return EBADMEM;
    128156
    129         return burst_out_test(dev->intr_out, cycles, size);
     157        // FIXME: report duration
     158        return burst_out_test(dev->intr_out, cycles, size, NULL);
    130159}
    131160
     
    136165                return EBADMEM;
    137166
    138         return burst_in_test(dev->bulk_in, cycles, size);
     167        // FIXME: report duration
     168        return burst_in_test(dev->bulk_in, cycles, size, NULL);
    139169}
    140170
     
    145175                return EBADMEM;
    146176
    147         return burst_out_test(dev->bulk_out, cycles, size);
     177        // FIXME: report duration
     178        return burst_out_test(dev->bulk_out, cycles, size, NULL);
    148179}
    149180
     
    154185                return EBADMEM;
    155186
    156         return burst_in_test(dev->isoch_in, cycles, size);
     187        // FIXME: report duration
     188        return burst_in_test(dev->isoch_in, cycles, size, NULL);
    157189}
    158190
     
    163195                return EBADMEM;
    164196
    165         return burst_out_test(dev->isoch_out, cycles, size);
     197        // FIXME: report duration
     198        return burst_out_test(dev->isoch_out, cycles, size, NULL);
    166199}
    167200
Note: See TracChangeset for help on using the changeset viewer.