Changeset 95155b0c in mainline
- Timestamp:
- 2006-12-19T10:12:24Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c8410ec9
- Parents:
- 7e7c8747
- Location:
- kernel
- Files:
-
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/func.h
r7e7c8747 r95155b0c 49 49 extern void strncpy(char *dest, const char *src, size_t len); 50 50 extern unative_t atoi(const char *text); 51 extern void order(const uint64_t val, uint64_t *rv, char *suffix); 51 52 52 53 #endif -
kernel/generic/src/console/cmd.c
r7e7c8747 r95155b0c 117 117 .argc = 1, 118 118 .argv = test_argv 119 }; 120 121 static int cmd_bench(cmd_arg_t *argv); 122 static cmd_arg_t bench_argv[] = { 123 { 124 .type = ARG_TYPE_STRING, 125 .buffer = test_buf, 126 .len = sizeof(test_buf) 127 }, 128 { 129 .type = ARG_TYPE_INT, 130 } 131 }; 132 static cmd_info_t bench_info = { 133 .name = "bench", 134 .description = "Run kernel test as benchmark.", 135 .func = cmd_bench, 136 .argc = 2, 137 .argv = bench_argv 119 138 }; 120 139 #endif … … 412 431 &tests_info, 413 432 &test_info, 433 &bench_info, 414 434 #endif 415 435 NULL … … 872 892 873 893 /* Execute the test */ 874 char * ret = test->entry( );894 char * ret = test->entry(false); 875 895 876 896 /* Update and read thread accounting */ … … 881 901 interrupts_restore(ipl); 882 902 883 printf("Time: %llu cycles\n", dt); 903 uint64_t cycles; 904 char suffix; 905 order(dt, &cycles, &suffix); 906 907 printf("Time: %llu%c cycles\n", cycles, suffix); 884 908 885 909 if (ret == NULL) { … … 890 914 printf("%s\n", ret); 891 915 return false; 916 } 917 918 static bool run_bench(const test_t *test, const uint32_t cnt) 919 { 920 uint32_t i; 921 bool ret = true; 922 uint64_t cycles; 923 char suffix; 924 925 if (cnt < 1) 926 return true; 927 928 uint64_t *data = malloc(sizeof(uint64_t) * cnt, 0); 929 if (data == NULL) { 930 printf("Error allocating memory for statistics\n"); 931 return false; 932 } 933 934 for (i = 0; i < cnt; i++) { 935 printf("%s (%d/%d) ... ", test->name, i + 1, cnt); 936 937 /* Update and read thread accounting 938 for benchmarking */ 939 ipl_t ipl = interrupts_disable(); 940 spinlock_lock(&TASK->lock); 941 uint64_t t0 = task_get_accounting(TASK); 942 spinlock_unlock(&TASK->lock); 943 interrupts_restore(ipl); 944 945 /* Execute the test */ 946 char * ret = test->entry(true); 947 948 /* Update and read thread accounting */ 949 ipl = interrupts_disable(); 950 spinlock_lock(&TASK->lock); 951 uint64_t dt = task_get_accounting(TASK) - t0; 952 spinlock_unlock(&TASK->lock); 953 interrupts_restore(ipl); 954 955 if (ret != NULL) { 956 printf("%s\n", ret); 957 ret = false; 958 break; 959 } 960 961 data[i] = dt; 962 order(dt, &cycles, &suffix); 963 printf("OK (%llu%c cycles)\n", cycles, suffix); 964 } 965 966 if (ret) { 967 printf("\n"); 968 969 uint64_t sum = 0; 970 971 for (i = 0; i < cnt; i++) { 972 sum += data[i]; 973 } 974 975 order(sum / (uint64_t) cnt, &cycles, &suffix); 976 printf("Average\t\t%llu%c\n", cycles, suffix); 977 } 978 979 free(data); 980 981 return ret; 892 982 } 893 983 … … 927 1017 return 1; 928 1018 } 1019 1020 /** Command for returning kernel tests as benchmarks 1021 * 1022 * @param argv Argument vector. 1023 * 1024 * return Always 1. 1025 */ 1026 int cmd_bench(cmd_arg_t *argv) 1027 { 1028 test_t *test; 1029 uint32_t cnt = argv[1].intval; 1030 1031 bool fnd = false; 1032 1033 for (test = tests; test->name != NULL; test++) { 1034 if (strcmp(test->name, argv->buffer) == 0) { 1035 fnd = true; 1036 run_bench(test, cnt); 1037 break; 1038 } 1039 } 1040 1041 if (!fnd) 1042 printf("Unknown test\n"); 1043 1044 return 1; 1045 } 1046 929 1047 #endif 930 1048 -
kernel/generic/src/lib/func.c
r7e7c8747 r95155b0c 222 222 } 223 223 224 225 void order(const uint64_t val, uint64_t *rv, char *suffix) 226 { 227 if (val > 1000000000000000000LL) { 228 *rv = val / 1000000000000000000LL; 229 *suffix = 'E'; 230 } else if (val > 1000000000000LL) { 231 *rv = val / 1000000000000LL; 232 *suffix = 'T'; 233 } else if (val > 1000000LL) { 234 *rv = val / 1000000LL; 235 *suffix = 'M'; 236 } else { 237 *rv = val; 238 *suffix = ' '; 239 } 240 } 241 224 242 /** @} 225 243 */ -
kernel/generic/src/proc/task.c
r7e7c8747 r95155b0c 53 53 #include <lib/elf.h> 54 54 #include <errno.h> 55 #include <func.h> 55 56 #include <syscall/copy.h> 56 57 #include <console/klog.h> … … 392 393 spinlock_lock(&t->lock); 393 394 394 uint64_t cycles = task_get_accounting(t);395 uint64_t cycles; 395 396 char suffix; 396 397 if (cycles > 1000000000000000000LL) { 398 cycles = cycles / 1000000000000000000LL; 399 suffix = 'E'; 400 } else if (cycles > 1000000000000LL) { 401 cycles = cycles / 1000000000000LL; 402 suffix = 'T'; 403 } else if (cycles > 1000000LL) { 404 cycles = cycles / 1000000LL; 405 suffix = 'M'; 406 } else 407 suffix = ' '; 397 order(task_get_accounting(t), &cycles, &suffix); 408 398 409 399 printf("%-6lld %-10s %-3ld %#10zx %#10zx %9llu%c %7zd %6zd", t->taskid, t->name, t->context, t, t->as, cycles, suffix, t->refcount, atomic_get(&t->active_calls)); -
kernel/generic/src/proc/thread.c
r7e7c8747 r95155b0c 570 570 uint64_t cycles; 571 571 char suffix; 572 573 if (t->cycles > 1000000000000000000LL) { 574 cycles = t->cycles / 1000000000000000000LL; 575 suffix = 'E'; 576 } else if (t->cycles > 1000000000000LL) { 577 cycles = t->cycles / 1000000000000LL; 578 suffix = 'T'; 579 } else if (t->cycles > 1000000LL) { 580 cycles = t->cycles / 1000000LL; 581 suffix = 'M'; 582 } else { 583 cycles = t->cycles; 584 suffix = ' '; 585 } 572 order(t->cycles, &cycles, &suffix); 586 573 587 574 printf("%-6zd %-10s %#10zx %-8s %#10zx %-3ld %#10zx %#10zx %9llu%c ", t->tid, t->name, t, thread_states[t->state], t->task, t->task->context, t->thread_code, t->kstack, cycles, suffix); -
kernel/test/atomic/atomic1.c
r7e7c8747 r95155b0c 32 32 #include <debug.h> 33 33 34 char * test_atomic1( void)34 char * test_atomic1(bool quiet) 35 35 { 36 36 atomic_t a; -
kernel/test/btree/btree1.c
r7e7c8747 r95155b0c 34 34 static void *data = (void *) 0xdeadbeef; 35 35 36 char * test_btree1( void)36 char * test_btree1(bool quiet) 37 37 { 38 38 btree_t t; … … 40 40 41 41 btree_create(&t); 42 43 printf("Inserting keys.\n"); 42 43 if (!quiet) 44 printf("Inserting keys.\n"); 44 45 btree_insert(&t, 19, data, NULL); 45 46 btree_insert(&t, 20, data, NULL); … … 77 78 for (i = 100; i >= 50; i--) 78 79 btree_insert(&t, i, data, NULL); 79 80 btree_print(&t);81 80 82 printf("Removing keys.\n"); 81 if (!quiet) 82 btree_print(&t); 83 84 if (!quiet) 85 printf("Removing keys.\n"); 83 86 btree_remove(&t, 50, NULL); 84 87 btree_remove(&t, 49, NULL); … … 155 158 btree_remove(&t, 35, NULL); 156 159 btree_remove(&t, 36, NULL); 157 158 btree_print(&t); 160 161 if (!quiet) 162 btree_print(&t); 159 163 160 164 return NULL; -
kernel/test/debug/mips1.c
r7e7c8747 r95155b0c 39 39 #include <arch.h> 40 40 41 char * test_mips1( void)41 char * test_mips1(bool quiet) 42 42 { 43 43 printf("You should enter kconsole debug mode now.\n"); -
kernel/test/fault/fault1.c
r7e7c8747 r95155b0c 38 38 39 39 40 char * test_fault1( void)40 char * test_fault1(bool quiet) 41 41 { 42 42 ((int *)(0))[1] = 0; -
kernel/test/fpu/fpu1.c
r7e7c8747 r95155b0c 174 174 } 175 175 176 char * test_fpu1( void)176 char * test_fpu1(bool quiet) 177 177 { 178 178 unsigned int i, total = 0; -
kernel/test/fpu/mips2.c
r7e7c8747 r95155b0c 111 111 112 112 113 char * test_mips2( void)113 char * test_mips2(bool quiet) 114 114 { 115 115 unsigned int i, total = 0; -
kernel/test/fpu/sse1.c
r7e7c8747 r95155b0c 110 110 111 111 112 char * test_sse1( void)112 char * test_sse1(bool quiet) 113 113 { 114 114 unsigned int i, total = 0; -
kernel/test/mm/falloc1.c
r7e7c8747 r95155b0c 41 41 #define TEST_RUNS 2 42 42 43 char * test_falloc1( void) {43 char * test_falloc1(bool quiet) { 44 44 uintptr_t * frames = (uintptr_t *) malloc(MAX_FRAMES * sizeof(uintptr_t), 0); 45 45 int results[MAX_ORDER + 1]; -
kernel/test/mm/falloc2.c
r7e7c8747 r95155b0c 100 100 } 101 101 102 char * test_falloc2( void)102 char * test_falloc2(bool quiet) 103 103 { 104 104 unsigned int i; -
kernel/test/mm/mapping1.c
r7e7c8747 r95155b0c 42 42 #define VALUE1 0x89abcdef 43 43 44 char * test_mapping1( void)44 char * test_mapping1(bool quiet) 45 45 { 46 46 uintptr_t frame0, frame1; -
kernel/test/mm/purge1.c
r7e7c8747 r95155b0c 42 42 extern void tlb_invalidate_pages(asid_t asid, uintptr_t va, count_t cnt); 43 43 44 char * test_purge1( void)44 char * test_purge1(bool quiet) 45 45 { 46 46 tlb_entry_t entryi; -
kernel/test/mm/slab1.c
r7e7c8747 r95155b0c 153 153 } 154 154 155 char * test_slab1( void)155 char * test_slab1(bool quiet) 156 156 { 157 157 testsimple(); -
kernel/test/mm/slab2.c
r7e7c8747 r95155b0c 206 206 } 207 207 208 char * test_slab2( void)208 char * test_slab2(bool quiet) 209 209 { 210 210 printf("Running reclaim single-thread test .. pass 1\n"); -
kernel/test/print/print1.c
r7e7c8747 r95155b0c 31 31 #define BUFFER_SIZE 32 32 32 33 char * test_print1( void)33 char * test_print1(bool quiet) 34 34 { 35 35 int retval; -
kernel/test/synch/rwlock1.c
r7e7c8747 r95155b0c 41 41 static rwlock_t rwlock; 42 42 43 char * test_rwlock1( void)43 char * test_rwlock1(bool quiet) 44 44 { 45 45 rwlock_initialize(&rwlock); -
kernel/test/synch/rwlock2.c
r7e7c8747 r95155b0c 56 56 } 57 57 58 char * test_rwlock2( void)58 char * test_rwlock2(bool quiet) 59 59 { 60 60 thread_t *thrd; -
kernel/test/synch/rwlock3.c
r7e7c8747 r95155b0c 56 56 } 57 57 58 char * test_rwlock3( void)58 char * test_rwlock3(bool quiet) 59 59 { 60 60 int i; -
kernel/test/synch/rwlock4.c
r7e7c8747 r95155b0c 114 114 } 115 115 116 char * test_rwlock4( void)116 char * test_rwlock4(bool quiet) 117 117 { 118 118 context_t ctx; -
kernel/test/synch/rwlock5.c
r7e7c8747 r95155b0c 67 67 } 68 68 69 char * test_rwlock5( void)69 char * test_rwlock5(bool quiet) 70 70 { 71 71 int i, j, k; -
kernel/test/synch/semaphore1.c
r7e7c8747 r95155b0c 70 70 } 71 71 72 char * test_semaphore1( void)72 char * test_semaphore1(bool quiet) 73 73 { 74 74 int i, j, k; -
kernel/test/synch/semaphore2.c
r7e7c8747 r95155b0c 82 82 } 83 83 84 char * test_semaphore2( void)84 char * test_semaphore2(bool quiet) 85 85 { 86 86 uint32_t i, k; -
kernel/test/sysinfo/sysinfo1.c
r7e7c8747 r95155b0c 33 33 #include <sysinfo/sysinfo.h> 34 34 35 char * test_sysinfo1( void)35 char * test_sysinfo1(bool quiet) 36 36 { 37 37 sysinfo_dump(NULL, 0); -
kernel/test/test.h
r7e7c8747 r95155b0c 39 39 #include <typedefs.h> 40 40 41 typedef char * (* test_entry_t)( );41 typedef char * (* test_entry_t)(bool); 42 42 43 43 typedef struct { … … 48 48 } test_t; 49 49 50 extern char * test_atomic1( void);51 extern char * test_btree1( void);52 extern char * test_mips1( void);53 extern char * test_fault1( void);54 extern char * test_fpu1( void);55 extern char * test_sse1( void);56 extern char * test_mips2( void);57 extern char * test_falloc1( void);58 extern char * test_falloc2( void);59 extern char * test_mapping1( void);60 extern char * test_purge1( void);61 extern char * test_slab1( void);62 extern char * test_slab2( void);63 extern char * test_rwlock1( void);64 extern char * test_rwlock2( void);65 extern char * test_rwlock3( void);66 extern char * test_rwlock4( void);67 extern char * test_rwlock5( void);68 extern char * test_semaphore1( void);69 extern char * test_semaphore2( void);70 extern char * test_print1( void);71 extern char * test_thread1( void);72 extern char * test_sysinfo1( void);50 extern char * test_atomic1(bool quiet); 51 extern char * test_btree1(bool quiet); 52 extern char * test_mips1(bool quiet); 53 extern char * test_fault1(bool quiet); 54 extern char * test_fpu1(bool quiet); 55 extern char * test_sse1(bool quiet); 56 extern char * test_mips2(bool quiet); 57 extern char * test_falloc1(bool quiet); 58 extern char * test_falloc2(bool quiet); 59 extern char * test_mapping1(bool quiet); 60 extern char * test_purge1(bool quiet); 61 extern char * test_slab1(bool quiet); 62 extern char * test_slab2(bool quiet); 63 extern char * test_rwlock1(bool quiet); 64 extern char * test_rwlock2(bool quiet); 65 extern char * test_rwlock3(bool quiet); 66 extern char * test_rwlock4(bool quiet); 67 extern char * test_rwlock5(bool quiet); 68 extern char * test_semaphore1(bool quiet); 69 extern char * test_semaphore2(bool quiet); 70 extern char * test_print1(bool quiet); 71 extern char * test_thread1(bool quiet); 72 extern char * test_sysinfo1(bool quiet); 73 73 74 74 extern test_t tests[]; -
kernel/test/thread/thread1.c
r7e7c8747 r95155b0c 53 53 } 54 54 55 char * test_thread1( void)55 char * test_thread1(bool quiet) 56 56 { 57 57 unsigned int i, total = 0;
Note:
See TracChangeset
for help on using the changeset viewer.