Changeset 7130754 in mainline
- Timestamp:
- 2024-01-03T16:48:56Z (13 months ago)
- Branches:
- master, topic/simplify-dev-export
- Children:
- de96d3b
- Parents:
- 550ed86
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2024-01-01 21:28:44)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2024-01-03 16:48:56)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/cmd.c
r550ed86 r7130754 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 … … 1582 1593 } 1583 1594 1595 int cmd_printbench(cmd_arg_t *argv) 1596 { 1597 int cnt = 20; 1598 1599 uint64_t *data = malloc(sizeof(uint64_t) * cnt); 1600 if (data == NULL) { 1601 printf("Error allocating memory for statistics\n"); 1602 return false; 1603 } 1604 1605 for (int i = 0; i < cnt; i++) { 1606 /* 1607 * Update and read thread accounting 1608 * for benchmarking 1609 */ 1610 irq_spinlock_lock(&TASK->lock, true); 1611 uint64_t ucycles0, kcycles0; 1612 task_get_accounting(TASK, &ucycles0, &kcycles0); 1613 irq_spinlock_unlock(&TASK->lock, true); 1614 1615 /* Execute the test */ 1616 for (int j = 0; j < 20; j++) { 1617 printf("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ěščřžýáíéú!@#$%%^&*(){}+\n"); 1618 printf("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ěščřžýáíéú!@#$%%^&*(){}+abcdefghijklmnopqrstuvwxyz\n"); 1619 printf("0123456789ěščřžýáíéú!@#$%%^&*(){}+abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\n"); 1620 } 1621 1622 /* Update and read thread accounting */ 1623 irq_spinlock_lock(&TASK->lock, true); 1624 uint64_t ucycles1, kcycles1; 1625 task_get_accounting(TASK, &ucycles1, &kcycles1); 1626 irq_spinlock_unlock(&TASK->lock, true); 1627 1628 data[i] = ucycles1 - ucycles0 + kcycles1 - kcycles0; 1629 } 1630 1631 printf("\n"); 1632 1633 uint64_t cycles; 1634 char suffix; 1635 uint64_t sum = 0; 1636 1637 for (int i = 0; i < cnt; i++) { 1638 sum += data[i]; 1639 } 1640 1641 order_suffix(sum / (uint64_t) cnt, &cycles, &suffix); 1642 printf("Average\t\t%" PRIu64 "%c\n", cycles, suffix); 1643 1644 free(data); 1645 1646 return true; 1647 } 1648 1584 1649 #endif 1585 1650
Note:
See TracChangeset
for help on using the changeset viewer.