Changes in kernel/generic/src/console/cmd.c [1871118:0f4f1b2] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/cmd.c
r1871118 r0f4f1b2 229 229 }; 230 230 231 /* Data and methods for 'printbench' command. */ 232 static int cmd_printbench(cmd_arg_t *argv); 233 234 static cmd_info_t printbench_info = { 235 .name = "printbench", 236 .description = "Run a printing benchmark.", 237 .func = cmd_printbench, 238 .argc = 0, 239 }; 240 231 241 #endif /* CONFIG_TEST */ 232 242 … … 613 623 &test_info, 614 624 &bench_info, 625 &printbench_info, 615 626 #endif 616 627 #ifdef CONFIG_UDEBUG … … 993 1004 printf("cpu%u: ", i); 994 1005 thread_wire(thread, &cpus[i]); 995 thread_ ready(thread_ref(thread));1006 thread_start(thread); 996 1007 thread_join(thread); 997 thread_put(thread);998 1008 } else 999 1009 printf("Unable to create thread for cpu%u\n", i); … … 1582 1592 } 1583 1593 1594 int cmd_printbench(cmd_arg_t *argv) 1595 { 1596 int cnt = 20; 1597 1598 uint64_t *data = malloc(sizeof(uint64_t) * cnt); 1599 if (data == NULL) { 1600 printf("Error allocating memory for statistics\n"); 1601 return false; 1602 } 1603 1604 for (int i = 0; i < cnt; i++) { 1605 /* 1606 * Update and read thread accounting 1607 * for benchmarking 1608 */ 1609 irq_spinlock_lock(&TASK->lock, true); 1610 uint64_t ucycles0, kcycles0; 1611 task_get_accounting(TASK, &ucycles0, &kcycles0); 1612 irq_spinlock_unlock(&TASK->lock, true); 1613 1614 /* Execute the test */ 1615 for (int j = 0; j < 20; j++) { 1616 printf("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ěščřžýáíéú!@#$%%^&*(){}+\n"); 1617 printf("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ěščřžýáíéú!@#$%%^&*(){}+abcdefghijklmnopqrstuvwxyz\n"); 1618 printf("0123456789ěščřžýáíéú!@#$%%^&*(){}+abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\n"); 1619 } 1620 1621 /* Update and read thread accounting */ 1622 irq_spinlock_lock(&TASK->lock, true); 1623 uint64_t ucycles1, kcycles1; 1624 task_get_accounting(TASK, &ucycles1, &kcycles1); 1625 irq_spinlock_unlock(&TASK->lock, true); 1626 1627 data[i] = ucycles1 - ucycles0 + kcycles1 - kcycles0; 1628 } 1629 1630 printf("\n"); 1631 1632 uint64_t cycles; 1633 char suffix; 1634 uint64_t sum = 0; 1635 1636 for (int i = 0; i < cnt; i++) { 1637 sum += data[i]; 1638 } 1639 1640 order_suffix(sum / (uint64_t) cnt, &cycles, &suffix); 1641 printf("Average\t\t%" PRIu64 "%c\n", cycles, suffix); 1642 1643 free(data); 1644 1645 return true; 1646 } 1647 1584 1648 #endif 1585 1649
Note:
See TracChangeset
for help on using the changeset viewer.