Changeset d5caf79 in mainline for uspace/app/perf/perf.c
- Timestamp:
- 2018-12-28T13:56:05Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 980611d5
- Parents:
- c7de81b
- git-author:
- Vojtech Horky <vojtech.horky@…> (2018-12-28 13:54:23)
- git-committer:
- Vojtech Horky <vojtech.horky@…> (2018-12-28 13:56:05)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/perf/perf.c
rc7de81b rd5caf79 43 43 #include <perf.h> 44 44 #include "perf.h" 45 #include "benchlist.h" 45 46 46 47 #define MIN_DURATION_SECS 10 47 48 #define NUM_SAMPLES 10 48 49 #define MAX_ERROR_STR_LENGTH 1024 49 50 benchmark_t benchmarks[] = {51 #include "ipc/ns_ping.def"52 #include "ipc/ping_pong.def"53 #include "malloc/malloc1.def"54 #include "malloc/malloc2.def"55 { NULL, NULL, NULL, NULL, NULL }56 };57 50 58 51 static void short_report(stopwatch_t *stopwatch, int run_index, … … 179 172 static int run_benchmarks(void) 180 173 { 181 benchmark_t *bench;182 174 unsigned int i = 0; 183 175 unsigned int n = 0; … … 187 179 printf("\n*** Running all benchmarks ***\n\n"); 188 180 189 for ( bench = benchmarks; bench->name != NULL; bench++) {190 printf("%s (%s)\n", bench ->name, bench->desc);191 if (run_benchmark(bench )) {181 for (size_t it = 0; it < benchmark_count; it++) { 182 printf("%s (%s)\n", benchmarks[it]->name, benchmarks[it]->desc); 183 if (run_benchmark(benchmarks[it])) { 192 184 i++; 193 185 continue; … … 195 187 196 188 if (!failed_names) { 197 failed_names = str_dup(bench ->name);189 failed_names = str_dup(benchmarks[it]->name); 198 190 } else { 199 191 char *f = NULL; 200 asprintf(&f, "%s, %s", failed_names, bench ->name);192 asprintf(&f, "%s, %s", failed_names, benchmarks[it]->name); 201 193 if (!f) { 202 194 printf("Out of memory.\n"); … … 219 211 { 220 212 size_t len = 0; 221 benchmark_t *bench;222 for (bench = benchmarks; bench->name != NULL; bench++) {223 if ( str_length(bench->name)> len)224 len = str_length(bench->name);213 for (size_t i = 0; i < benchmark_count; i++) { 214 size_t len_now = str_length(benchmarks[i]->name); 215 if (len_now > len) 216 len = len_now; 225 217 } 226 218 … … 231 223 } 232 224 233 for ( bench = benchmarks; bench->name != NULL; bench++)234 printf("%-*s %s\n", _len, bench ->name, bench->desc);225 for (size_t i = 0; i < benchmark_count; i++) 226 printf("%-*s %s\n", _len, benchmarks[i]->name, benchmarks[i]->desc); 235 227 236 228 printf("%-*s Run all benchmarks\n", _len, "*"); … … 250 242 } 251 243 252 benchmark_t *bench; 253 for (bench = benchmarks; bench->name != NULL; bench++) { 254 if (str_cmp(argv[1], bench->name) == 0) { 255 return (run_benchmark(bench) ? 0 : -1); 244 for (size_t i = 0; i < benchmark_count; i++) { 245 if (str_cmp(argv[1], benchmarks[i]->name) == 0) { 246 return (run_benchmark(benchmarks[i]) ? 0 : -1); 256 247 } 257 248 }
Note:
See TracChangeset
for help on using the changeset viewer.