#include <assert.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <set>
#include <rpa/platforms.h>
#include <rpa/synchro.h>
#include <rpa/testing.h>
#include <rpa/containers/vector.h>
#include <rpa/containers/set.h>
#include <rpa/containers/row_iterator.h>
#include <rpa/containers/streambuf_tmpnam.h>
#include <rpa/testing_streambuf.h>
#include <rpa/algorithms/transform.h>
#include <rpa/istream_iterator_delimiter.h>
Classes | |
class | DataIn |
After the template specializations, comes the library. More... | |
class | DataOut |
class | T18In2Out |
class | TestRow< OutStrmBuf, RowBufferType > |
struct | Tst_T18< TmpNamOutStrmBuf > |
For an output stream class, tests 'transform' with many output buffers types. More... | |
Defines | |
#define | DATAIN_BINARY_IO |
#define | DATAOUT_BINARY_IO |
#define | THR_FACTOR 3 |
Functions | |
void | CompareT18 (DataOut *aPtr, size_t aSz, const char *aRangeName, const char *aDelim, std::basic_streambuf< char > &aStreamBuf) |
int | main (int aArgC, const char **aArgV) |
Tst_T18. | |
Variables | |
static const rpa::thr_nb_t | myNbThr = THR_FACTOR * THR_FACTOR |
static rpa::testing_thread | myThrTests [myNbThr] |
static const size_t | myMaxElts = 200000 * TST_RATIO |
static DataOut | mySample [myMaxElts] |
This contains the output results that each algorithm must calculate. | |
static DataIn | myInputArr [myMaxElts] |
static std::set< DataIn > | myInputSet |
#define DATAIN_BINARY_IO |
Much faster and convenient than using iostreams. Both methods are possible anyway.
#define DATAOUT_BINARY_IO |
Much faster than using iostream for writing data into a file. Both methods are possible anyway.
#define THR_FACTOR 3 |
The maximum number of threads. In the loop on threads, they are multiplied by three at each loop.
void CompareT18 | ( | DataOut * | aPtr, | |
size_t | aSz, | |||
const char * | aRangeName, | |||
const char * | aDelim, | |||
std::basic_streambuf< char > & | aStreamBuf | |||
) |
It is not necessary to sort the input elements because they are put at initialisation time in a vector which is naturally sorted.
Go back to the beginning of the stream buffer.
This is used for reading the data with the original delimiter.
Go back to the beginning of the stream buffer.
This reads the output result of the algorithm, and puts the elements in a multiset. The data type must be deserializable given the delimiter.
int main | ( | int | aArgC, | |
const char ** | aArgV | |||
) |
Tries different types of per-thread buffers. Writes into different sorts of outputs, as long as they are streams. NOTE: We do not attempt to test obuf_iterator with a stream as buffer and a non-ostream_iterator_public output. It may make sense, I do not know yet.
At the end, it is compared against the algorithms output. It is not necessary to sort the input elements because they are given a numerical index.
Fills the containers. The algorithm 'transform' will convert to a DataIn. The content will never be changed.
It is possible to use any kind of input container, but here we concentrate on a plain array.
DataIn myInputArr[myMaxElts] [static] |
These are the input container types. They are very big, and therefore not put on the stack.
std::set< DataIn > myInputSet [static] |
const size_t myMaxElts = 200000 * TST_RATIO [static] |
Maximum number of input data. The ratio is made for adjusting the testing time.
const rpa::thr_nb_t myNbThr = THR_FACTOR * THR_FACTOR [static] |
This contains the output results that each algorithm must calculate.
rpa::testing_thread myThrTests[myNbThr] [static] |
The threads must be global because we have no idea about when they are actually created or stopped. They can be stored in any kind of container as long as threads are not copied nor assigned. This contains a pool of threads we want to use.