Changeset 64ce0c1 in mainline for uspace/app/tmon
- Timestamp:
- 2018-02-02T10:13:55Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 961a5ee
- Parents:
- e67c50a (diff), 290338b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/app/tmon
- Files:
-
- 1 added
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tmon/Makefile
re67c50a r64ce0c1 30 30 BINARY = tmon 31 31 32 LIBS = drv 32 LIBS = drv usb 33 33 34 34 SOURCES = \ … … 36 36 list.c\ 37 37 tf.c\ 38 burst_tests.c\38 tests.c\ 39 39 resolve.c 40 40 -
uspace/app/tmon/commands.h
re67c50a r64ce0c1 42 42 int tmon_list(int, char **); 43 43 44 /* Burst tests read/write into endpoints as fast as possible. */45 int tmon_ burst_intr_in(int, char **);46 int tmon_ burst_intr_out(int, char **);47 int tmon_ burst_bulk_in(int, char **);48 int tmon_ burst_bulk_out(int, char **);49 int tmon_ burst_isoch_in(int, char **);50 int tmon_ burst_isoch_out(int, char **);44 /* Tests commands differ by endpoint types. */ 45 int tmon_test_intr_in(int, char **); 46 int tmon_test_intr_out(int, char **); 47 int tmon_test_bulk_in(int, char **); 48 int tmon_test_bulk_out(int, char **); 49 int tmon_test_isoch_in(int, char **); 50 int tmon_test_isoch_out(int, char **); 51 51 52 52 #endif /* TMON_COMMANDS_H_ */ -
uspace/app/tmon/main.c
re67c50a r64ce0c1 64 64 .name = "test-intr-in", 65 65 .description = "Read from interrupt endpoint as fast as possible.", 66 .action = tmon_ burst_intr_in,66 .action = tmon_test_intr_in, 67 67 }, 68 68 { 69 69 .name = "test-intr-out", 70 70 .description = "Write to interrupt endpoint as fast as possible.", 71 .action = tmon_ burst_intr_out,71 .action = tmon_test_intr_out, 72 72 }, 73 73 { 74 74 .name = "test-bulk-in", 75 75 .description = "Read from bulk endpoint as fast as possible.", 76 .action = tmon_ burst_bulk_in,76 .action = tmon_test_bulk_in, 77 77 }, 78 78 { 79 79 .name = "test-bulk-out", 80 80 .description = "Write to bulk endpoint as fast as possible.", 81 .action = tmon_ burst_bulk_out,81 .action = tmon_test_bulk_out, 82 82 }, 83 83 { 84 84 .name = "test-isoch-in", 85 85 .description = "Read from isochronous endpoint as fast as possible.", 86 .action = tmon_ burst_isoch_in,86 .action = tmon_test_isoch_in, 87 87 }, 88 88 { 89 89 .name = "test-isoch-out", 90 90 .description = "Write to isochronous endpoint as fast as possible.", 91 .action = tmon_ burst_isoch_out,92 } 91 .action = tmon_test_isoch_out, 92 }, 93 93 }; 94 94 … … 106 106 static tmon_opt_t options[] = { 107 107 { 108 .long_name = " cycles",109 .short_name = ' n',110 .description = "Set the number of read/write cycles."108 .long_name = "duration", 109 .short_name = 't', 110 .description = "Set the minimum test duration (in seconds)." 111 111 }, 112 112 { 113 113 .long_name = "size", 114 114 .short_name = 's', 115 .description = "Set the data size transferred in a single cycle." 116 } 115 .description = "Set the data size (in bytes) transferred in a single cycle." 116 }, 117 { 118 .long_name = "validate", 119 .short_name = 'v', 120 .description = "Validate the correctness of transferred data (impacts performance)." 121 }, 117 122 }; 118 123 -
uspace/app/tmon/tf.c
re67c50a r64ce0c1 36 36 37 37 #include <stdio.h> 38 #include <macros.h> 38 39 #include <devman.h> 39 40 #include <str_error.h> … … 74 75 } 75 76 76 printf(" Using device: %s\n", path);77 printf("Device: %s\n", path); 77 78 78 79 // Read test parameters from options. 79 tmon_test_params_t*params = NULL;80 void *params = NULL; 80 81 if ((rc = ops->read_params(argc, argv, ¶ms))) { 81 82 printf(NAME ": Reading test parameters failed. %s\n", str_error(rc)); 83 return 1; 84 } 85 86 if ((rc = ops->pre_run(params))) { 87 printf(NAME ": Pre-run hook failed. %s\n", str_error(rc)); 82 88 return 1; 83 89 } … … 106 112 } 107 113 114 /** Unit of quantity used for pretty formatting. */ 115 typedef struct tmon_unit { 116 /** Prefix letter, which is printed before the actual unit. */ 117 const char *unit; 118 /** Factor of the unit. */ 119 double factor; 120 } tmon_unit_t; 121 122 /** Format a value for human reading. 123 * @param[in] val The value to format. 124 * @param[in] fmt Format string. Must include one double and char. 125 * 126 * @return Heap-allocated string if successful (caller becomes its owner), NULL otherwise. 127 */ 128 static char *format_unit(double val, const char *fmt, const tmon_unit_t *units, size_t len) 129 { 130 // Figure out the "tightest" unit. 131 unsigned i; 132 for (i = 0; i < len; ++i) { 133 if (units[i].factor <= val) 134 break; 135 } 136 137 if (i == len) --i; 138 const char *unit = units[i].unit; 139 double factor = units[i].factor; 140 141 // Format the size. 142 const double div_size = val / factor; 143 144 char *out = NULL; 145 asprintf(&out, fmt, div_size, unit); 146 147 return out; 148 } 149 150 /** Static array of size units with decreasing factors. */ 151 static const tmon_unit_t size_units[] = { 152 { .unit = "EB", .factor = 1ULL << 60 }, 153 { .unit = "PB", .factor = 1ULL << 50 }, 154 { .unit = "TB", .factor = 1ULL << 40 }, 155 { .unit = "GB", .factor = 1ULL << 30 }, 156 { .unit = "MB", .factor = 1ULL << 20 }, 157 { .unit = "kB", .factor = 1ULL << 10 }, 158 { .unit = "B", .factor = 1ULL }, 159 }; 160 161 char *tmon_format_size(double val, const char *fmt) 162 { 163 return format_unit(val, fmt, size_units, ARRAY_SIZE(size_units)); 164 } 165 166 /** Static array of duration units with decreasing factors. */ 167 static const tmon_unit_t dur_units[] = { 168 { .unit = "d", .factor = 60 * 60 * 24 }, 169 { .unit = "h", .factor = 60 * 60 }, 170 { .unit = "min", .factor = 60 }, 171 { .unit = "s", .factor = 1 }, 172 { .unit = "ms", .factor = 1e-3 }, 173 { .unit = "us", .factor = 1e-6 }, 174 { .unit = "ns", .factor = 1e-9 }, 175 { .unit = "ps", .factor = 1e-12 }, 176 }; 177 178 char *tmon_format_duration(usbdiag_dur_t val, const char *fmt) 179 { 180 return format_unit(val / 1000.0, fmt, dur_units, ARRAY_SIZE(dur_units)); 181 } 182 108 183 /** @} 109 184 */ -
uspace/app/tmon/tf.h
re67c50a r64ce0c1 38 38 39 39 #include <async.h> 40 41 /** Parameters common for all tests. */ 42 typedef struct tmon_test_params { 43 /* Nothing here. */ 44 } tmon_test_params_t; 40 #include <usbdiag_iface.h> 45 41 46 42 /** Operations to implement by all tests. */ 47 43 typedef struct tmon_test_ops { 48 int (*run)(async_exch_t *, const tmon_test_params_t *); 49 int (*read_params)(int, char **, tmon_test_params_t **); 44 int (*pre_run)(void *); 45 int (*run)(async_exch_t *, const void *); 46 int (*read_params)(int, char **, void **); 50 47 } tmon_test_ops_t; 51 48 52 49 int tmon_test_main(int, char **, const tmon_test_ops_t *); 50 51 char *tmon_format_size(double, const char *); 52 char *tmon_format_duration(usbdiag_dur_t, const char *); 53 53 54 54 #endif /* TMON_TF_H_ */
Note:
See TracChangeset
for help on using the changeset viewer.
