40 std::cerr <<
"Usage: benchmarks [option]" << std::endl
42 <<
"Option:" << std::endl
43 <<
" --nb -n number of odd numbers to check by range (100 by default)" << std::endl;
55 main(
int argc,
const char*
const argv[]) {
69 for (
unsigned int i = 1; i < static_cast<unsigned int>(argc); ++i) {
70 const std::string param(argv[i]);
72 if (param ==
"--nb") {
86 std::cout <<
"Nb: " << nb << std::endl;
90 std::cout << std::endl
91 <<
"First n\tLast n\tNb\tNaive\tFactorize\tFactorize bound\tEuler" 116 std::chrono::duration<double> total_duration = std::chrono::duration<double>(0);
121 ? std::min(firsts[i + 1] - 2, first + (nb - 1)*2)
126 const unsigned int repeat = (last < 100000
129 const double duration_coef = 1000000.0;
134 std::cout << first <<
'\t' << last <<
'\t' << current_nb;
138 if (first <= 100000000000000) {
140 const std::chrono::steady_clock::time_point clock_start = std::chrono::steady_clock::now();
142 for (
unsigned int k = 0; k < repeat; ++k) {
150 #pragma GCC diagnostic push 151 #pragma GCC diagnostic ignored "-Wunused-but-set-variable" 152 volatile const std::pair<sigmaodd::nat_type, unsigned int> result_length
154 #pragma GCC diagnostic pop 158 const std::chrono::duration<double> duration = std::chrono::steady_clock::now() - clock_start;
160 std::cout <<
'\t' << duration.count()*duration_coef/
static_cast<double>(real_nb);
161 total_duration += duration;
171 const std::chrono::steady_clock::time_point clock_start = std::chrono::steady_clock::now();
173 for (
unsigned int k = 0; k < repeat; ++k) {
181 #pragma GCC diagnostic push 182 #pragma GCC diagnostic ignored "-Wunused-but-set-variable" 183 volatile const std::pair<sigmaodd::nat_type, unsigned int> result_length
185 #pragma GCC diagnostic pop 189 const std::chrono::duration<double> duration = std::chrono::steady_clock::now() - clock_start;
191 std::cout <<
'\t' << duration.count()*duration_coef/
static_cast<double>(real_nb);
192 total_duration += duration;
199 const std::chrono::steady_clock::time_point clock_start = std::chrono::steady_clock::now();
201 for (
unsigned int k = 0; k < repeat; ++k) {
209 #pragma GCC diagnostic push 210 #pragma GCC diagnostic ignored "-Wunused-but-set-variable" 211 volatile const std::pair<sigmaodd::nat_type, unsigned int> result_length
213 #pragma GCC diagnostic pop 217 const std::chrono::duration<double> duration = std::chrono::steady_clock::now() - clock_start;
219 std::cout <<
'\t' << duration.count()*duration_coef/
static_cast<double>(real_nb);
220 total_duration += duration;
226 const std::chrono::steady_clock::time_point clock_start = std::chrono::steady_clock::now();
228 for (
unsigned int k = 0; k < repeat; ++k) {
236 #pragma GCC diagnostic push 237 #pragma GCC diagnostic ignored "-Wunused-but-set-variable" 238 volatile const std::pair<sigmaodd::nat_type, unsigned int> result_length
240 #pragma GCC diagnostic pop 244 const std::chrono::duration<double> duration = std::chrono::steady_clock::now() - clock_start;
246 std::cout <<
'\t' << duration.count()*duration_coef/
static_cast<double>(real_nb);
247 total_duration += duration;
250 std::cout << std::endl;
253 std::cerr <<
"Total duration (for all calculation): " int main(int argc, const char *const argv[])
uint64_t nat_type
Type for natural number used in all code, on 64 bits.
constexpr bool is_odd(nat_type n)
Return true iff n is odd.
std::pair< nat_type, unsigned int > sum_odd_divisors_divided_until_odd_iterate_until_lower__factorize(nat_type n)
Iterates the sum_odd_divisors_divided_until_odd__factorize() function from n until have a result lowe...
const std::string prime_filename
Default filename for the binary file "big_data/prime28.bin".
Functions to calculate pentagonal numbers and one useless algorithm that used the Euler formula to ca...
std::pair< nat_type, unsigned int > sum_odd_divisors_divided_until_odd_iterate_until_lower__factorize_bound(nat_type n)
Iterates the sum_odd_divisors_divided_until_odd__factorize() function from n until have a result lowe...
std::string duration_to_string(std::chrono::duration< double > duration_second)
Return a string with the duration expressed in milliseconds, seconds, minutes and hours...
std::size_t sum_divisors__euler_cache_nb()
Return the current number of items in the cache used by sum_divisors__euler()
std::pair< nat_type, unsigned int > sum_odd_divisors_divided_until_odd_iterate_until_lower__euler(nat_type n)
Iterates the sum_odd_divisors_divided_until_odd__euler() function from n until have a result lower th...
bool read_primes_table()
Read the binary file prime_filename to fill the table with all primes < 2^28. This table must be read...
Functions to access to tables of precaculated prime numbers and offsets to iterate on possible prime ...
std::pair< nat_type, unsigned int > sum_odd_divisors_divided_until_odd_iterate_until_lower__naive(nat_type n)
Iterates the sum_odd_divisors_divided_until_odd__naive() function from n until have a result lower th...
Some generic helper functions for programs.
void print_intern_config_compiler()
Print to stdcout the intern configuration of the compiler.
constexpr bool is_little_mersenne_prime_unitary_divide(nat_type n)
Return true iff at least one of 3, 7, 31, 127, 8191, 131071 or 524287 is an unitary divisor of n...
Main functions to deal the sigma_odd problem.
unsigned long get_ulong(int argc, const char *const argv[], unsigned int i, void(*help_and_exit_function)())
Return argv[i] converted in integer.