cmd_dhry.c 845 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * (C) Copyright 2015 Google, Inc
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <command.h>
  8. #include <div64.h>
  9. #include "dhry.h"
  10. static int do_dhry(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  11. {
  12. ulong start, duration, vax_mips;
  13. u64 dhry_per_sec;
  14. int iterations = 1000000;
  15. if (argc > 1)
  16. iterations = simple_strtoul(argv[1], NULL, 10);
  17. start = get_timer(0);
  18. dhry(iterations);
  19. duration = get_timer(start);
  20. dhry_per_sec = lldiv(iterations * 1000ULL, duration);
  21. vax_mips = lldiv(dhry_per_sec, 1757);
  22. printf("%d iterations in %lu ms: %lu/s, %lu DMIPS\n", iterations,
  23. duration, (ulong)dhry_per_sec, vax_mips);
  24. return 0;
  25. }
  26. U_BOOT_CMD(
  27. dhry, 2, 1, do_dhry,
  28. "[iterations] - run dhrystone benchmark",
  29. "\n - run the Dhrystone 2.1 benchmark, a rough measure of CPU speed\n"
  30. );