Changes in kernel/generic/src/console/cmd.c [aafed15:f35749e] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/cmd.c
raafed15 rf35749e 1 1 /* 2 * Copyright (c) 2025 Jiri Svoboda 2 3 * Copyright (c) 2005 Jakub Jermar 3 4 * All rights reserved. … … 60 61 #include <arch/mm/tlb.h> 61 62 #include <mm/frame.h> 63 #include <main/shutdown.h> 62 64 #include <main/version.h> 63 65 #include <mm/slab.h> … … 227 229 .argc = 2, 228 230 .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, 229 241 }; 230 242 … … 613 625 &test_info, 614 626 &bench_info, 627 &printbench_info, 615 628 #endif 616 629 #ifdef CONFIG_UDEBUG … … 993 1006 printf("cpu%u: ", i); 994 1007 thread_wire(thread, &cpus[i]); 995 thread_ ready(thread);1008 thread_start(thread); 996 1009 thread_join(thread); 997 thread_detach(thread);998 1010 } else 999 1011 printf("Unable to create thread for cpu%u\n", i); … … 1582 1594 } 1583 1595 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 accounting 1609 * for benchmarking 1610 */ 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 1584 1650 #endif 1585 1651
Note:
See TracChangeset
for help on using the changeset viewer.