#include <assert.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <rpa/platforms.h>
#include <rpa/architectures/posix.h>
#include <rpa/algorithms/transform.h>
#include <rpa/testing.h>
Classes | |
struct | FunctorCharPtr2String |
This functor will be applied to each argument of the command line. More... | |
class | CmpWithoutMtx |
When there is no input mutex, and atomic range_step must be used. More... | |
Defines | |
#define | NB_THR 5 |
Our thread pool. The threads are 'create'-d by the algorithm. | |
#define | NB_LOOPS 20 |
#define | NB_SAMPLES ( ( ( 1 << 20 ) + 1 ) * TST_RATIO ) |
Typedefs | |
typedef rpa::testing_mutex | mtx_t |
typedef std::vector< std::string > | VecStrT |
typedef std::back_insert_iterator< VecStrT > | BackInsT |
typedef rpa::range_step< const char *const *, void > | RngStepAtomicT |
Functions | |
template<class Range> | |
static VecStrT | t_nobuf (Range aRng) |
Test without output buffer, but with a mutex to protect the output. | |
template<class Range, size_t BufSiz> | |
static VecStrT | t19_limit_noall (Range aRng) |
template<class Range, size_t BufSiz> | |
static VecStrT | t19_limit_alloc (Range aRng) |
static void | mainIntern (int aArgC, const char *const *aArgV, size_t aStep) |
int | main (int aArgC, const char **aArgV) |
Loops on internal data and on the command line. | |
Variables | |
static rpa::testing_thread * | myThr = NULL |
static mtx_t * | myMtxOutput = NULL |
static char | myStr [NB_SAMPLES][RPA_INT_STR] |
This buffer is a global variable because it may be too big for the stack. | |
static char * | myPtr [NB_SAMPLES] |
This buffer is a global variable because it may be too big for the stack. |
#define NB_LOOPS 20 |
#define NB_SAMPLES ( ( ( 1 << 20 ) + 1 ) * TST_RATIO ) |
Adjusted as a power of two, plus one. The ratio can globally adjust the time taken by tests.
#define NB_THR 5 |
Our thread pool. The threads are 'create'-d by the algorithm.
This because we want to use the algorithm 'transform'.
typedef rpa::testing_mutex mtx_t |
Tests are done with different mutex for the input and the output, but also with the same one, to prove that using the same mutex does not imply a deadlock. A dependency between these two mutex may happen because the user has the possibility to use any datatype as a mutex. And some external resources may have unpredictable side effects.
typedef rpa::range_step< const char * const *, void > RngStepAtomicT |
typedef std::vector< std::string > VecStrT |
int main | ( | int | aArgC, | |
const char ** | aArgV | |||
) |
Loops on internal data and on the command line.
Tests dynamic allocation.
Tries with several chunks size for the dynamic scheduling policy. The numbers are intentionnaly chosen as 'disturbing'.
An internal number set as a maximum 'reasonable' number.
Tries the algorithm with various sizes, much smaller and much bigger than the number of threads and the size of buffers. The number of elements starts with 0, then 1, and then is multiplied by four at each loop.
static void mainIntern | ( | int | aArgC, | |
const char *const * | aArgV, | |||
size_t | aStep | |||
) | [static] |
Tests the various output sequences configurations. Run the tests with several mutex for the input :
We try different fixed buffer sizes.
We try different fixed buffer sizes.
static VecStrT t19_limit_alloc | ( | Range | aRng | ) | [static] |
static VecStrT t19_limit_noall | ( | Range | aRng | ) | [static] |
Test without output buffer, but with a mutex to protect the output.
mtx_t* myMtxOutput = NULL [static] |
char* myPtr[NB_SAMPLES] [static] |
This buffer is a global variable because it may be too big for the stack.
char myStr[NB_SAMPLES][RPA_INT_STR] [static] |
This buffer is a global variable because it may be too big for the stack.
rpa::testing_thread* myThr = NULL [static] |