You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

70 lines
1.8 KiB

  1. //
  2. // Lol Engine - Benchmark program
  3. //
  4. // Copyright: (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the Do What The Fuck You Want To
  7. // Public License, Version 2, as published by Sam Hocevar. See
  8. // http://sam.zoy.org/projects/COPYING.WTFPL for more details.
  9. //
  10. #if defined HAVE_CONFIG_H
  11. # include "config.h"
  12. #endif
  13. #include <cstdio>
  14. #include "core.h"
  15. using namespace std;
  16. using namespace lol;
  17. static size_t const REAL_TABLE_SIZE = 10000;
  18. static size_t const REAL_RUNS = 50;
  19. void bench_real(int mode)
  20. {
  21. float result[12] = { 0.0f };
  22. Timer timer;
  23. for (size_t run = 0; run < REAL_RUNS; run++)
  24. {
  25. switch (mode)
  26. {
  27. case 1:
  28. break;
  29. }
  30. real fib1 = 1.0, fib2 = 1.0;
  31. timer.GetMs();
  32. for (size_t i = 0; i < REAL_TABLE_SIZE; i++)
  33. {
  34. real tmp = fib1 + fib2;
  35. fib1 = fib2;
  36. fib2 = tmp;
  37. }
  38. result[0] += timer.GetMs();
  39. real fact = 1.0;
  40. timer.GetMs();
  41. for (size_t i = 0; i < REAL_TABLE_SIZE; i++)
  42. fact = fact * real(1.0 + i);
  43. result[1] += timer.GetMs();
  44. real invfact = 1.0;
  45. timer.GetMs();
  46. for (size_t i = 0; i < REAL_TABLE_SIZE; i++)
  47. invfact = invfact / real(1.0 + i);
  48. result[2] += timer.GetMs();
  49. }
  50. for (size_t i = 0; i < sizeof(result) / sizeof(*result); i++)
  51. result[i] *= 1000000.0f / (REAL_TABLE_SIZE * REAL_RUNS);
  52. Log::Info(" ns/elem\n");
  53. Log::Info("real = real + real %7.3f\n", result[0]);
  54. Log::Info("real = real * real %7.3f\n", result[1]);
  55. Log::Info("real = real / real %7.3f\n", result[2]);
  56. }