Advertisement
thezxtreme

perf test

Jan 14th, 2020
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. static std::vector<uint16_t> order_lengths = { 1869, 2238, 3000, 4000, 4219, 6238, 7338, 8469 };
  2. static std::vector<uint32_t> order_counts = { 30, 80, 60, 60, 30, 30, 60, 30 };
  3.  
  4. static std::vector<uint16_t> pattern_lengths = { 2238, 7338, 8469 };
  5. static std::vector<uint32_t> pattern_counts = { 5, 3, 2 };
  6.  
  7. auto test1() -> uint16_t
  8. {
  9. uint16_t result = 0;
  10.  
  11. for (std::size_t i(0x0); i < pattern_lengths.size(); ++i)
  12. {
  13. for (std::size_t j(0x0); j < order_lengths.size(); ++j)
  14. {
  15. const uint16_t order_length = order_lengths[j];
  16. const uint16_t pattern_length = pattern_lengths[i];
  17.  
  18. if (order_length > pattern_length)
  19. return 0;
  20.  
  21. if (order_length != pattern_length)
  22. continue;
  23.  
  24. const uint32_t order_count = order_counts[j];
  25. const uint32_t pattern_count = pattern_counts[i];
  26.  
  27. if (order_count < pattern_count)
  28. return 0;
  29.  
  30. result = (!result) ? uint16_t(order_count / pattern_count) : std::min(result, uint16_t(order_count / pattern_count));
  31. break;
  32. }
  33. }
  34. return result;
  35. }
  36.  
  37. static std::vector<Edesia::Cut> t2_order = { {1869, 30}, {2238, 80},{3000, 60},{4000, 60},{4219, 30},{6238, 30},{7338, 60}, {8469, 30}};
  38. static std::vector<Edesia::Cut> t2_pattern = { {2238, 5}, {7338, 3}, {8469, 2} };
  39.  
  40. auto test2() -> uint16_t
  41. {
  42. uint16_t result = 0;
  43.  
  44. for (const Edesia::Cut& cut : t2_pattern)
  45. {
  46. for (const Edesia::Cut& _cut : t2_order)
  47. {
  48. if (_cut.length > cut.length)
  49. return 0;
  50.  
  51. if (_cut.length != cut.length)
  52. continue;
  53.  
  54. if (_cut.count < cut.count)
  55. return 0;
  56.  
  57. result = (!result) ? uint16_t(_cut.count / cut.count) : std::min(result, uint16_t(_cut.count / cut.count));
  58. break;
  59. }
  60. }
  61. return result;
  62. }
  63.  
  64. auto main() -> int
  65. {
  66. for (int i = 0; i < 10000000; ++i)
  67. test2();
  68.  
  69. return EXIT_SUCCESS;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement