Changes in kernel/generic/src/console/cmd.c [f35749e:aafed15] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/cmd.c
rf35749e raafed15 1 1 /* 2 * Copyright (c) 2025 Jiri Svoboda3 2 * Copyright (c) 2005 Jakub Jermar 4 3 * All rights reserved. … … 61 60 #include <arch/mm/tlb.h> 62 61 #include <mm/frame.h> 63 #include <main/shutdown.h>64 62 #include <main/version.h> 65 63 #include <mm/slab.h> … … 229 227 .argc = 2, 230 228 .argv = bench_argv 231 };232 233 /* Data and methods for 'printbench' command. */234 static int cmd_printbench(cmd_arg_t *argv);235 236 static cmd_info_t printbench_info = {237 .name = "printbench",238 .description = "Run a printing benchmark.",239 .func = cmd_printbench,240 .argc = 0,241 229 }; 242 230 … … 625 613 &test_info, 626 614 &bench_info, 627 &printbench_info,628 615 #endif 629 616 #ifdef CONFIG_UDEBUG … … 1006 993 printf("cpu%u: ", i); 1007 994 thread_wire(thread, &cpus[i]); 1008 thread_ start(thread);995 thread_ready(thread); 1009 996 thread_join(thread); 997 thread_detach(thread); 1010 998 } else 1011 999 printf("Unable to create thread for cpu%u\n", i); … … 1594 1582 } 1595 1583 1596 int cmd_printbench(cmd_arg_t *argv)1597 {1598 int cnt = 20;1599 1600 uint64_t *data = malloc(sizeof(uint64_t) * cnt);1601 if (data == NULL) {1602 printf("Error allocating memory for statistics\n");1603 return false;1604 }1605 1606 for (int i = 0; i < cnt; i++) {1607 /*1608 * Update and read thread accounting1609 * for benchmarking1610 */1611 irq_spinlock_lock(&TASK->lock, true);1612 uint64_t ucycles0, kcycles0;1613 task_get_accounting(TASK, &ucycles0, &kcycles0);1614 irq_spinlock_unlock(&TASK->lock, true);1615 1616 /* Execute the test */1617 for (int j = 0; j < 20; j++) {1618 printf("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ěščřžýáíéú!@#$%%^&*(){}+\n");1619 printf("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ěščřžýáíéú!@#$%%^&*(){}+abcdefghijklmnopqrstuvwxyz\n");1620 printf("0123456789ěščřžýáíéú!@#$%%^&*(){}+abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\n");1621 }1622 1623 /* Update and read thread accounting */1624 irq_spinlock_lock(&TASK->lock, true);1625 uint64_t ucycles1, kcycles1;1626 task_get_accounting(TASK, &ucycles1, &kcycles1);1627 irq_spinlock_unlock(&TASK->lock, true);1628 1629 data[i] = ucycles1 - ucycles0 + kcycles1 - kcycles0;1630 }1631 1632 printf("\n");1633 1634 uint64_t cycles;1635 char suffix;1636 uint64_t sum = 0;1637 1638 for (int i = 0; i < cnt; i++) {1639 sum += data[i];1640 }1641 1642 order_suffix(sum / (uint64_t) cnt, &cycles, &suffix);1643 printf("Average\t\t%" PRIu64 "%c\n", cycles, suffix);1644 1645 free(data);1646 1647 return true;1648 }1649 1650 1584 #endif 1651 1585
Note:
See TracChangeset
for help on using the changeset viewer.