cmd_dhry.c 799 B

12345678910111213141516171819202122232425262728293031323334
  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 "dhry.h"
  9. static int do_dhry(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  10. {
  11. ulong start, duration, dhry_per_sec, vax_mips;
  12. int iterations = 1000000;
  13. if (argc > 1)
  14. iterations = simple_strtoul(argv[1], NULL, 10);
  15. start = get_timer(0);
  16. dhry(iterations);
  17. duration = get_timer(start);
  18. dhry_per_sec = iterations * 1000 / duration;
  19. vax_mips = dhry_per_sec / 1757;
  20. printf("%d iterations in %lu ms: %lu/s, %lu DMIPS\n", iterations,
  21. duration, dhry_per_sec, vax_mips);
  22. return 0;
  23. }
  24. U_BOOT_CMD(
  25. dhry, 2, 1, do_dhry,
  26. "[iterations] - run dhrystone benchmark",
  27. "\n - run the Dhrystone 2.1 benchmark, a rough measure of CPU speed\n"
  28. );