Rev 2027 | Rev 2039 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2027 | Rev 2030 | ||
---|---|---|---|
Line 67... | Line 67... | ||
67 | 67 | ||
68 | #ifdef CONFIG_TEST |
68 | #ifdef CONFIG_TEST |
69 | #include <test.h> |
69 | #include <test.h> |
70 | #endif |
70 | #endif |
71 | 71 | ||
72 | #ifdef CONFIG_BENCH |
- | |
73 | #include <arch/cycle.h> |
- | |
74 | #endif |
- | |
75 | - | ||
76 | /* Data and methods for 'help' command. */ |
72 | /* Data and methods for 'help' command. */ |
77 | static int cmd_help(cmd_arg_t *argv); |
73 | static int cmd_help(cmd_arg_t *argv); |
78 | static cmd_info_t help_info = { |
74 | static cmd_info_t help_info = { |
79 | .name = "help", |
75 | .name = "help", |
80 | .description = "List of supported commands.", |
76 | .description = "List of supported commands.", |
Line 863... | Line 859... | ||
863 | } |
859 | } |
864 | 860 | ||
865 | static bool run_test(const test_t * test) |
861 | static bool run_test(const test_t * test) |
866 | { |
862 | { |
867 | printf("%s\t\t%s\n", test->name, test->desc); |
863 | printf("%s\t\t%s\n", test->name, test->desc); |
- | 864 | ||
- | 865 | /* Update and read thread accounting |
|
868 | #ifdef CONFIG_BENCH |
866 | for benchmarking */ |
- | 867 | ipl_t ipl = interrupts_disable(); |
|
- | 868 | spinlock_lock(&THREAD->lock); |
|
- | 869 | thread_update_accounting(); |
|
869 | uint64_t t0 = get_cycle(); |
870 | uint64_t t0 = THREAD->cycles; |
- | 871 | spinlock_unlock(&THREAD->lock); |
|
- | 872 | interrupts_restore(ipl); |
|
870 | #endif |
873 | |
- | 874 | /* Execute the test */ |
|
871 | char * ret = test->entry(); |
875 | char * ret = test->entry(); |
- | 876 | ||
- | 877 | /* Update and read thread accounting */ |
|
872 | #ifdef CONFIG_BENCH |
878 | ipl = interrupts_disable(); |
- | 879 | spinlock_lock(&THREAD->lock); |
|
- | 880 | thread_update_accounting(); |
|
873 | uint64_t dt = get_cycle() - t0; |
881 | uint64_t dt = THREAD->cycles - t0; |
- | 882 | spinlock_unlock(&THREAD->lock); |
|
- | 883 | interrupts_restore(ipl); |
|
- | 884 | ||
874 | printf("Time: %llu cycles\n", dt); |
885 | printf("Time: %llu cycles\n", dt); |
875 | #endif |
- | |
876 | 886 | ||
877 | if (ret == NULL) { |
887 | if (ret == NULL) { |
878 | printf("Test passed\n"); |
888 | printf("Test passed\n"); |
879 | return true; |
889 | return true; |
880 | } |
890 | } |