PLearn 0.1
|
The first sentence should be a BRIEF DESCRIPTION of what the class does. More...
#include <MemoryStressTest.h>
Public Member Functions | |
MemoryStressTest () | |
Default constructor. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual MemoryStressTest * | deepCopy (CopiesMap &copies) const |
virtual void | build () |
Post-constructor. | |
virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Transforms a shallow copy into a deep copy. | |
virtual void | perform () |
The method performing the test. | |
Static Public Member Functions | |
static string | _classname_ () |
static OptionList & | _getOptionList_ () |
static RemoteMethodMap & | _getRemoteMethodMap_ () |
static Object * | _new_instance_for_typemap_ () |
static bool | _isa_ (const Object *o) |
static void | _static_initialize_ () |
static const PPath & | declaringFile () |
Public Attributes | |
int | N |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declares the class options. | |
static void | nullary (const PythonCodeSnippet *python) |
Static members and methods used in the test. | |
static void | unary (const PythonCodeSnippet *python) |
static void | binary (const PythonCodeSnippet *python) |
static void | ternary (const PythonCodeSnippet *python) |
static void | quaternary (const PythonCodeSnippet *python) |
Static Protected Attributes | |
static string | python_code = " return a,b,c,d\n" |
Static Python code. | |
Private Types | |
typedef PTest | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
The first sentence should be a BRIEF DESCRIPTION of what the class does.
Place the rest of the class programmer documentation here. Doxygen supports Javadoc-style comments. See http://www.doxygen.org/manual.html
Definition at line 61 of file MemoryStressTest.h.
typedef PTest PLearn::MemoryStressTest::inherited [private] |
Reimplemented from PLearn::PTest.
Definition at line 63 of file MemoryStressTest.h.
PLearn::MemoryStressTest::MemoryStressTest | ( | ) |
Default constructor.
Definition at line 68 of file MemoryStressTest.cc.
: N(10000) { // ... // ### You may (or not) want to call build_() to finish building the object // ### (doing so assumes the parent classes' build_() have been called too // ### in the parent classes' constructors, something that you must ensure) }
string PLearn::MemoryStressTest::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 63 of file MemoryStressTest.cc.
OptionList & PLearn::MemoryStressTest::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 63 of file MemoryStressTest.cc.
RemoteMethodMap & PLearn::MemoryStressTest::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 63 of file MemoryStressTest.cc.
Reimplemented from PLearn::PTest.
Definition at line 63 of file MemoryStressTest.cc.
Object * PLearn::MemoryStressTest::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 63 of file MemoryStressTest.cc.
StaticInitializer MemoryStressTest::_static_initializer_ & PLearn::MemoryStressTest::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 63 of file MemoryStressTest.cc.
void PLearn::MemoryStressTest::binary | ( | const PythonCodeSnippet * | python | ) | [static, protected] |
Definition at line 233 of file MemoryStressTest.cc.
References PLearn::PythonObjectWrapper::as(), and PLearn::PythonCodeSnippet::invoke().
Referenced by perform().
{
TVec<int> v = python->invoke("binary",2,4).as< TVec<int> >();
}
void PLearn::MemoryStressTest::build | ( | ) | [virtual] |
Post-constructor.
The normal implementation should call simply inherited::build(), then this class's build_(). This method should be callable again at later times, after modifying some option fields to change the "architecture" of the object.
Reimplemented from PLearn::PTest.
Definition at line 81 of file MemoryStressTest.cc.
References PLearn::PTest::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::MemoryStressTest::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::PTest.
Definition at line 125 of file MemoryStressTest.cc.
Referenced by build().
{ // ### This method should do the real building of the object, // ### according to set 'options', in *any* situation. // ### Typical situations include: // ### - Initial building of an object from a few user-specified options // ### - Building of a "reloaded" object: i.e. from the complete set of all serialised options. // ### - Updating or "re-building" of an object after a few "tuning" options have been modified. // ### You should assume that the parent class' build_() has already been called. }
string PLearn::MemoryStressTest::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 63 of file MemoryStressTest.cc.
void PLearn::MemoryStressTest::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares the class options.
Reimplemented from PLearn::PTest.
Definition at line 107 of file MemoryStressTest.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::PTest::declareOptions(), and N.
{ // ### Declare all of this object's options here // ### For the "flags" of each option, you should typically specify // ### one of OptionBase::buildoption, OptionBase::learntoption or // ### OptionBase::tuningoption. Another possible flag to be combined with // ### is OptionBase::nosave declareOption(ol, "N", &MemoryStressTest::N, OptionBase::buildoption, "Number of iterations to perform."); // Now call the parent class' declareOptions inherited::declareOptions(ol); }
static const PPath& PLearn::MemoryStressTest::declaringFile | ( | ) | [inline, static] |
MemoryStressTest * PLearn::MemoryStressTest::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 63 of file MemoryStressTest.cc.
OptionList & PLearn::MemoryStressTest::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 63 of file MemoryStressTest.cc.
OptionMap & PLearn::MemoryStressTest::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 63 of file MemoryStressTest.cc.
RemoteMethodMap & PLearn::MemoryStressTest::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 63 of file MemoryStressTest.cc.
void PLearn::MemoryStressTest::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::PTest.
Definition at line 90 of file MemoryStressTest.cc.
References PLearn::PTest::makeDeepCopyFromShallowCopy(), and PLERROR.
{ inherited::makeDeepCopyFromShallowCopy(copies); // ### Call deepCopyField on all "pointer-like" fields // ### that you wish to be deepCopied rather than // ### shallow-copied. // ### ex: // deepCopyField(trainvec, copies); // ### Remove this line when you have fully implemented this method. PLERROR("MemoryStressTest::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!"); }
void PLearn::MemoryStressTest::nullary | ( | const PythonCodeSnippet * | python | ) | [static, protected] |
Static members and methods used in the test.
Definition at line 189 of file MemoryStressTest.cc.
References PLearn::PythonCodeSnippet::invoke().
Referenced by perform().
{
python->invoke("nullary");
}
void PLearn::MemoryStressTest::perform | ( | ) | [virtual] |
The method performing the test.
A typical test consists in some output (to pout and / or perr), and updates of this object's options.
Reimplemented from PLearn::PTest.
Definition at line 251 of file MemoryStressTest.cc.
References binary(), i, N, nullary(), python_code, quaternary(), ternary(), unary(), and PLearn::ProgressBar::update().
{ PP<PythonCodeSnippet> python = new PythonCodeSnippet(python_code); python->build(); ProgressBar pb("Invoking Python Functions", N); for (int i=0 ; i<N ; ++i) { pb.update(i); nullary(python); unary(python); binary(python); ternary(python); quaternary(python); } }
void PLearn::MemoryStressTest::quaternary | ( | const PythonCodeSnippet * | python | ) | [static, protected] |
Definition at line 243 of file MemoryStressTest.cc.
References PLearn::PythonObjectWrapper::as(), and PLearn::PythonCodeSnippet::invoke().
Referenced by perform().
{
TVec<int> v = python->invoke("quaternary",2,4,8,16).as< TVec<int> >();
}
void PLearn::MemoryStressTest::ternary | ( | const PythonCodeSnippet * | python | ) | [static, protected] |
Definition at line 238 of file MemoryStressTest.cc.
References PLearn::PythonObjectWrapper::as(), and PLearn::PythonCodeSnippet::invoke().
Referenced by perform().
{
TVec<int> v = python->invoke("ternary",2,4,8).as< TVec<int> >();
}
void PLearn::MemoryStressTest::unary | ( | const PythonCodeSnippet * | python | ) | [static, protected] |
Definition at line 194 of file MemoryStressTest.cc.
References PLearn::PythonObjectWrapper::as(), d, i, PLearn::PythonCodeSnippet::invoke(), m, PLearn::openString(), PLearn::PStream::plearn_ascii, and PLearn::TMat< T >::toVec().
Referenced by perform().
{ int i = python->invoke("unary_int", 42).as<int>(); unsigned long long l = python->invoke("unary_long", 18446744073709551615ULL).as<unsigned long long>(); double d = python->invoke("unary_float", 42.01).as<double>(); string s = python->invoke("unary_str", "Hello").as<string>(); i = i; l = l; d = d; Vec v; string str_v = "[2,3,5,7,11,13,17,19,23]"; PStream is = openString(str_v, PStream::plearn_ascii); is >> v; Mat m(3,3); m.toVec() << v; Vec py_vec = python->invoke("unary_vec", v).as<Vec>(); Mat py_mat = python->invoke("unary_mat", m).as<Mat>(); TVec<string> tvs; string str_tvs = "[\"Cela\", \"est\", \"juste\", \"et\", \"bon\"]"; PStream is_tvs = openString(str_tvs, PStream::plearn_ascii); is_tvs >> tvs; vector<string> vecs(tvs.begin(), tvs.end()); TVec<string> py_tvs = python->invoke("unary_list_str", tvs).as< TVec<string> >(); vector<string> py_vecs = python->invoke("unary_list_str", vecs).as< vector<string> >(); map<string,int64_t> mapsd; string str_mapsd = "{ Oui:16 il:32 est:64 juste:128 et:256 bon:512 }"; PStream is_mapsd = openString(str_mapsd, PStream::plearn_ascii); is_mapsd >> mapsd; map<string,int64_t> py_mapsd = python->invoke("unary_dict", mapsd).as< map<string,int64_t> >(); }
Reimplemented from PLearn::PTest.
Definition at line 86 of file MemoryStressTest.h.
Definition at line 68 of file MemoryStressTest.h.
Referenced by declareOptions(), and perform().