sf_performance.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. ///////////////////////////////////////////////////////////////
  2. // Copyright 2011 John Maddock. Distributed under the Boost
  3. // Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
  5. #include "sf_performance.hpp"
  6. unsigned allocation_count = 0;
  7. void* (*alloc_func_ptr)(size_t);
  8. void* (*realloc_func_ptr)(void*, size_t, size_t);
  9. void (*free_func_ptr)(void*, size_t);
  10. void* alloc_func(size_t n)
  11. {
  12. ++allocation_count;
  13. return (*alloc_func_ptr)(n);
  14. }
  15. void free_func(void* p, size_t n)
  16. {
  17. (*free_func_ptr)(p, n);
  18. }
  19. void* realloc_func(void* p, size_t old, size_t n)
  20. {
  21. ++allocation_count;
  22. return (*realloc_func_ptr)(p, old, n);
  23. }
  24. int main()
  25. {
  26. using namespace boost::multiprecision;
  27. #if defined(TEST_MPFR) || defined(TEST_MPFR_CLASS) || defined(TEST_MPREAL) || defined(TEST_MPF)
  28. mp_get_memory_functions(&alloc_func_ptr, &realloc_func_ptr, &free_func_ptr);
  29. mp_set_memory_functions(&alloc_func, &realloc_func, &free_func);
  30. #endif
  31. basic_tests();
  32. bessel_tests();
  33. poly_tests();
  34. nct_tests();
  35. }