Changeset d5caf79 in mainline
- Timestamp:
- 2018-12-28T13:56:05Z (6 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)
- Location:
- uspace/app/perf
- Files:
-
- 2 added
- 4 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/perf/Makefile
rc7de81b rd5caf79 34 34 35 35 SOURCES = \ 36 benchlist.c \ 36 37 perf.c \ 37 38 ipc/ns_ping.c \ -
uspace/app/perf/ipc/ns_ping.c
rc7de81b rd5caf79 32 32 #include <errno.h> 33 33 #include <str_error.h> 34 #include "../benchlist.h" 34 35 #include "../perf.h" 35 36 36 bool bench_ns_ping(stopwatch_t *stopwatch, uint64_t niter,37 static bool runner(stopwatch_t *stopwatch, uint64_t niter, 37 38 char *error, size_t error_size) 38 39 { … … 54 55 return true; 55 56 } 57 58 benchmark_t bench_ns_ping = { 59 .name = "ns_ping", 60 .desc = "Name service IPC ping-pong benchmark", 61 .entry = &runner, 62 .setup = NULL, 63 .teardown = NULL 64 }; -
uspace/app/perf/ipc/ping_pong.c
rc7de81b rd5caf79 32 32 #include <errno.h> 33 33 #include <str_error.h> 34 #include "../benchlist.h" 34 35 #include "../perf.h" 35 36 36 37 static ipc_test_t *test = NULL; 37 38 38 bool bench_ping_pong_setup(char *error, size_t error_size)39 static bool setup(char *error, size_t error_size) 39 40 { 40 41 errno_t rc = ipc_test_create(&test); … … 49 50 } 50 51 51 bool bench_ping_pong_teardown(char *error, size_t error_size)52 static bool teardown(char *error, size_t error_size) 52 53 { 53 54 ipc_test_destroy(test); … … 55 56 } 56 57 57 bool bench_ping_pong(stopwatch_t *stopwatch, uint64_t niter,58 static bool runner(stopwatch_t *stopwatch, uint64_t niter, 58 59 char *error, size_t error_size) 59 60 { … … 75 76 return true; 76 77 } 78 79 benchmark_t bench_ping_pong = { 80 .name = "ping_pong", 81 .desc = "IPC ping-pong benchmark", 82 .entry = &runner, 83 .setup = &setup, 84 .teardown = &teardown 85 }; -
uspace/app/perf/malloc/malloc1.c
rc7de81b rd5caf79 30 30 #include <stdio.h> 31 31 #include <stdlib.h> 32 #include "../benchlist.h" 32 33 #include "../perf.h" 33 34 34 bool bench_malloc1(stopwatch_t *stopwatch, uint64_t size,35 static bool runner(stopwatch_t *stopwatch, uint64_t size, 35 36 char *error, size_t error_size) 36 37 { … … 50 51 return true; 51 52 } 53 54 benchmark_t bench_malloc1 = { 55 .name = "malloc1", 56 .desc = "User-space memory allocator benchmark, repeatedly allocate one block", 57 .entry = &runner, 58 .setup = NULL, 59 .teardown = NULL 60 }; -
uspace/app/perf/malloc/malloc2.c
rc7de81b rd5caf79 29 29 #include <stdlib.h> 30 30 #include <stdio.h> 31 #include "../benchlist.h" 31 32 #include "../perf.h" 32 33 33 bool bench_malloc2(stopwatch_t *stopwatch, uint64_t niter,34 static bool runner(stopwatch_t *stopwatch, uint64_t niter, 34 35 char *error, size_t error_size) 35 36 { … … 67 68 return true; 68 69 } 70 71 benchmark_t bench_malloc2 = { 72 .name = "malloc2", 73 .desc = "User-space memory allocator benchmark, allocate many small blocks", 74 .entry = &runner, 75 .setup = NULL, 76 .teardown = NULL 77 }; -
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 } -
uspace/app/perf/perf.h
rc7de81b rd5caf79 51 51 } benchmark_t; 52 52 53 extern bool bench_malloc1(stopwatch_t *, uint64_t, char *, size_t);54 extern bool bench_malloc2(stopwatch_t *, uint64_t, char *, size_t);55 extern bool bench_ns_ping(stopwatch_t *, uint64_t, char *, size_t);56 extern bool bench_ping_pong(stopwatch_t *, uint64_t, char *, size_t);57 extern bool bench_ping_pong_setup(char *, size_t);58 extern bool bench_ping_pong_teardown(char *, size_t);59 60 extern benchmark_t benchmarks[];61 62 53 #endif 63 54
Note:
See TracChangeset
for help on using the changeset viewer.