cmd_dhry.c 838 B

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