main.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include <library/cpp/int128/int128.h>
  2. #include <library/cpp/testing/benchmark/bench.h>
  3. #include <util/generic/xrange.h>
  4. #include <util/system/compiler.h>
  5. Y_CPU_BENCHMARK(LibraryDivisionUnsigned128, iface) {
  6. ui128 b = {0, 10'000'000};
  7. for (const auto i : xrange(iface.Iterations())) {
  8. ui128 a = i * 10'000'000;
  9. ui128 c = a / b;
  10. Y_FAKE_READ(c);
  11. }
  12. }
  13. #if defined(Y_HAVE_INT128)
  14. Y_CPU_BENCHMARK(IntrinsicDivisionUnsigned128, iface) {
  15. unsigned __int128 b = 10'000'000;
  16. for (const auto i : xrange(iface.Iterations())) {
  17. unsigned __int128 a = i * 10'000'000;
  18. unsigned __int128 c = a / b;
  19. Y_FAKE_READ(c);
  20. }
  21. }
  22. #endif // Y_HAVE_INT128
  23. Y_CPU_BENCHMARK(LibraryDivisionSigned128, iface) {
  24. i128 b = {0, 10'000'000};
  25. for (const auto i : xrange(iface.Iterations())) {
  26. i128 a = i * 10'000'000;
  27. i128 c = a / b;
  28. Y_FAKE_READ(c);
  29. }
  30. }
  31. #if defined(Y_HAVE_INT128)
  32. Y_CPU_BENCHMARK(IntrinsicDivisionSigned128, iface) {
  33. signed __int128 b = 10'000'000;
  34. for (const auto i : xrange(iface.Iterations())) {
  35. signed __int128 a = i * 10'000'000;
  36. signed __int128 c = a / b;
  37. Y_FAKE_READ(c);
  38. }
  39. }
  40. #endif // Y_HAVE_INT128