41 std::cerr <<
"Usage: benchmarks [option]" << std::endl
43 <<
"Option:" << std::endl
44 <<
" --nb n number of odd numbers to check by range (100 by default)" << std::endl;
56 main(
int argc,
const char*
const argv[]) {
72 for (
unsigned int i = 1; i < static_cast<unsigned int>(argc); ++i) {
73 const std::string param(argv[i]);
75 if (param ==
"--nb") {
94 std::cout <<
"First: " << first
96 <<
"\tNb: " << nb << std::endl;
100 std::cout << std::endl
101 <<
" \t \t/# nb tested\t/# nb naturals\t% tested" << std::endl;
106 std::chrono::duration<double> total_duration = std::chrono::duration<double>(0);
112 const std::chrono::steady_clock::time_point clock_start = std::chrono::steady_clock::now();
121 #pragma GCC diagnostic push 122 #pragma GCC diagnostic ignored "-Wunused-but-set-variable" 123 volatile const std::pair<sigmaodd::nat_type, unsigned int> result_length
125 #pragma GCC diagnostic pop 128 const std::chrono::duration<double> duration = std::chrono::steady_clock::now() - clock_start;
130 std::cout <<
"Factorize\taverage:\t" 131 <<
static_cast<double>(duration.count())/static_cast<double>(real_nb) <<
" s\t" 132 <<
static_cast<double>(duration.count())/static_cast<double>(nb*2) <<
" s\t" 133 <<
static_cast<double>(real_nb*100)/static_cast<double>(nb*2) <<
"%" 135 total_duration += duration;
142 const std::chrono::steady_clock::time_point clock_start = std::chrono::steady_clock::now();
151 #pragma GCC diagnostic push 152 #pragma GCC diagnostic ignored "-Wunused-but-set-variable" 153 volatile const std::pair<sigmaodd::nat_type, unsigned int> result_length
155 #pragma GCC diagnostic pop 158 const std::chrono::duration<double> duration = std::chrono::steady_clock::now() - clock_start;
160 std::cout <<
"Factorize bound\taverage:\t" 161 <<
static_cast<double>(duration.count())/static_cast<double>(real_nb) <<
" s\t" 162 <<
static_cast<double>(duration.count())/static_cast<double>(nb*2) <<
" s\t" 163 <<
static_cast<double>(real_nb*100)/static_cast<double>(nb*2) <<
"%" 165 total_duration += duration;
168 std::cerr <<
"Total duration (for all calculation): " 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...
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 ...
Some generic helper functions for programs.
int main(int argc, const char *const argv[])
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.