Changes in kernel/generic/src/console/cmd.c [0f4f1b2:1871118] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/cmd.c
r0f4f1b2 r1871118 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 241 231 #endif /* CONFIG_TEST */ 242 232 … … 623 613 &test_info, 624 614 &bench_info, 625 &printbench_info,626 615 #endif 627 616 #ifdef CONFIG_UDEBUG … … 1004 993 printf("cpu%u: ", i); 1005 994 thread_wire(thread, &cpus[i]); 1006 thread_ start(thread);995 thread_ready(thread_ref(thread)); 1007 996 thread_join(thread); 997 thread_put(thread); 1008 998 } else 1009 999 printf("Unable to create thread for cpu%u\n", i); … … 1592 1582 } 1593 1583 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 accounting1607 * for benchmarking1608 */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 1648 1584 #endif 1649 1585
Note:
See TracChangeset
for help on using the changeset viewer.