Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/console/cmd.c

    rf35749e raafed15  
    11/*
    2  * Copyright (c) 2025 Jiri Svoboda
    32 * Copyright (c) 2005 Jakub Jermar
    43 * All rights reserved.
     
    6160#include <arch/mm/tlb.h>
    6261#include <mm/frame.h>
    63 #include <main/shutdown.h>
    6462#include <main/version.h>
    6563#include <mm/slab.h>
     
    229227        .argc = 2,
    230228        .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,
    241229};
    242230
     
    625613        &test_info,
    626614        &bench_info,
    627         &printbench_info,
    628615#endif
    629616#ifdef CONFIG_UDEBUG
     
    1006993                        printf("cpu%u: ", i);
    1007994                        thread_wire(thread, &cpus[i]);
    1008                         thread_start(thread);
     995                        thread_ready(thread);
    1009996                        thread_join(thread);
     997                        thread_detach(thread);
    1010998                } else
    1011999                        printf("Unable to create thread for cpu%u\n", i);
     
    15941582}
    15951583
    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 
    16501584#endif
    16511585
Note: See TracChangeset for help on using the changeset viewer.