Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / multiprecision / performance / sf_performance.cpp
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
6 #include "sf_performance.hpp"
7
8 unsigned allocation_count = 0;
9
10 void* (*alloc_func_ptr)(size_t);
11 void* (*realloc_func_ptr)(void*, size_t, size_t);
12 void (*free_func_ptr)(void*, size_t);
13
14 void* alloc_func(size_t n)
15 {
16    ++allocation_count;
17    return (*alloc_func_ptr)(n);
18 }
19
20 void free_func(void* p, size_t n)
21 {
22    (*free_func_ptr)(p, n);
23 }
24
25 void* realloc_func(void* p, size_t old, size_t n)
26 {
27    ++allocation_count;
28    return (*realloc_func_ptr)(p, old, n);
29 }
30
31 int main()
32 {
33    using namespace boost::multiprecision;
34
35 #if defined(TEST_MPFR) || defined(TEST_MPFR_CLASS) || defined(TEST_MPREAL) || defined(TEST_MPF)
36    mp_get_memory_functions(&alloc_func_ptr, &realloc_func_ptr, &free_func_ptr);
37    mp_set_memory_functions(&alloc_func, &realloc_func, &free_func);
38 #endif
39
40    basic_tests();
41    bessel_tests();
42    poly_tests();
43    nct_tests();
44 }