25ValueTolerance::ValueTolerance() {
33ValueTolerance::ValueTolerance(
double val,
double tol) {
41ValueTolerance::ValueTolerance(
double val,
double low,
double up) {
46 use_tolerance =
false;
49ValueTolerance::ValueTolerance(std::string str) {
53bool ValueTolerance::operator ==(ValueTolerance& rhs) {
54 return (value == rhs.value) &&
55 (tolerance == rhs.tolerance) &&
56 (lower == rhs.lower) &&
57 (upper == rhs.upper) &&
58 (use_tolerance == rhs.use_tolerance);
61std::string ValueTolerance::as_string(){
62 std::ostringstream strs;
64 strs << value <<
" , " << tolerance;
66 strs << value <<
" , " << lower <<
" , " << upper;
70void ValueTolerance::from_string(
const std::string& valtol_str) {
71 std::string value_str = valtol_str.substr(0,valtol_str.find(
","));
72 value = atof(value_str.c_str());
73 std::string tol_str = valtol_str.substr(valtol_str.find(
",")+1);
74 if(tol_str.find(
",")<=tol_str.length()) {
75 use_tolerance =
false;
76 std::string lower_str = tol_str.substr(0,tol_str.find(
","));
77 lower = atof(lower_str.c_str());
78 std::string upper_str = tol_str.substr(tol_str.find(
",")+1);
79 upper = atof(upper_str.c_str());
82 tolerance = atof(tol_str.c_str());
86 XMLTestNode::XMLTestNode():XMLObject() {}
88 XMLTestNode::XMLTestNode(
const std::string &tag):XMLObject(tag) {}
90 XMLTestNode::XMLTestNode(XMLObjectImplem *ptr):XMLObject(ptr) {}
92 XMLTestNode::XMLTestNode(XMLObject obj):XMLObject(obj) {}
94 void XMLTestNode::addDouble (
const std::string &name,
double val) {
95 addAttribute<double>(name,val);
98 void XMLTestNode::addInt (
const std::string &name,
int val) {
99 addAttribute<int>(name,val);
102 void XMLTestNode::addBool (
const std::string &name,
bool val) {
103 addAttribute<bool>(name,val);
106 void XMLTestNode::addValueTolerance(
const std::string &name, ValueTolerance val){
107 addAttribute<std::string>(name,val.as_string());
110 void XMLTestNode::addString (
const std::string &name, std::string val) {
111 addAttribute<std::string>(name,val);
114 bool XMLTestNode::hasChild(
const std::string &name)
const {
116 for(
int i = 0; i < numChildren(); i++) {
117 if(name.compare(XMLObject::getChild(i).getTag()) == 0) {
125 void XMLTestNode::appendContentLine(
const size_t& i,
const std::string &str) {
126 ptr_->appendContentLine(i,str);
129 XMLTestNode XMLTestNode::getChild(
const std::string &name)
const {
131 for(
int i = 0; i < numChildren(); i++) {
132 if(name.compare(XMLObject::getChild(i).getTag()) == 0)
133 child = XMLObject::getChild(i);
138 XMLTestNode XMLTestNode::getChild(
const int &i)
const {
139 return XMLObject::getChild(i);
142 const XMLObject* XMLTestNode::xml_object()
const {
143 return (XMLObject*)
this;
146 bool XMLTestNode::hasSameElements(XMLTestNode
const & lhs)
const {
148 if((numChildren()!=lhs.numChildren()) ||
149 (numContentLines()!= lhs.numContentLines()) ||
150 (getTag().compare(lhs.getTag())!=0))
return false;
152 for(
int i = 0; i<numChildren(); i++) {
153 const XMLTestNode child = XMLObject::getChild(i);
154 if( (!lhs.hasChild(child.getTag())) ||
155 (!child.hasSameElements(lhs.getChild(child.getTag()))) )
return false;
158 for(
int i = 0; i<numContentLines(); i++)
159 if(getContentLine(i).compare(lhs.getContentLine(i))!=0)
return false;
167 std::string
cpuname(
"Undefined");
173 std::ifstream
cpuinfo(
"/proc/cpuinfo");
175 if((
cpuinfo.rdstate()&
cpuinfo.failbit)) std::cout<<
"Failed to open filen\n";
178 if (line.find(
"model name") < line.size()) {
179 cpuname = line.substr(line.find(
":")+2);
182 if (line.find(
"physical id") < line.size()) {
183 unsigned int socketid = atoi(line.substr(line.find(
":")+2).c_str());
186 if (line.find(
"cpu cores") < line.size()) {
196 machine_config.addInt(
"Compiler_Version", TEUCHOS_COMPILER_VERSION);
217 if (std::ifstream (
filename.c_str ())) {
240 for (
int i = 0;
i <
machine.numChildren (); ++
i) {
244 std::runtime_error,
"Unexpected Tag \"" <<
configuration.getTag ()
245 <<
"\"; only children with Tag = \"Configuration\" are allowed in a "
252 "A Configuration needs to have a child \"MachineConfiguration\" and a "
267 for (
int k = 0;
k <
old_test.numChildren (); ++
k) {
273 std::runtime_error,
"A TestEntry needs to have a child "
274 "\"TestConfiguration\" and a child \"TestResults\".");
314 std::cout << std::endl
315 <<
"DeviationA in Test: \"" <<
old_test.getTag()
316 <<
"\" for entry \"" <<
result_entry.getTag() <<
"\"" << std::endl;
317 std::cout <<
" Existing Value: \"" <<
oldv_str <<
"\"" << std::endl;
318 std::cout <<
" New Value: \"" <<
new_results.getChild(
result_entry.getTag()).getContentLine(0) <<
"\"" << std::endl << std::endl;
323 std::cout << std::endl
324 <<
"DeviationB in Test: \"" <<
old_test.getTag()
325 <<
"\" for entry \"" <<
result_entry.getTag() <<
"\"" << std::endl;
326 std::cout <<
" Existing Value: \"" <<
oldv_str <<
"\"" << std::endl;
327 std::cout <<
" New Value: \"" <<
new_results.getChild(
result_entry.getTag()).getContentLine(0) <<
"\"" << std::endl << std::endl;
334 std::cout << std::endl
335 <<
"DeviationC in Test: \"" <<
old_test.getTag()
336 <<
"\" for entry \"" <<
result_entry.getTag() <<
"\"" << std::endl;
337 std::cout <<
" Existing Value: \"" <<
oldv_str <<
"\"" << std::endl;
338 std::cout <<
" New Value: \"" <<
new_results.getChild(
result_entry.getTag()).getContentLine(0) <<
"\"" << std::endl << std::endl;
344 std::cout <<
"Error New test has same name as an existing one, but one of the old entries is missing." << std::endl;
An object representation of a subset of XML data.
Tools for an XML-based performance test archive.
Smart reference counting pointer class for automatic garbage collection.
Subclass of XMLObject used by the performance archive.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
XMLTestNode PerfTest_MachineConfig()
PerfTest_MachineConfig generates a basic machine configuration XMLTestNode.
PerfTestResult
ReturnValues for PerfTest_CheckOrAdd_Test.
PerfTestResult PerfTest_CheckOrAdd_Test(XMLTestNode machine_config, XMLTestNode new_test, const std::string filename, const std::string ext_hostname)
Check whether a test is present and match an existing test in an archive.
ValueTolerance is a struct to keep a tuple of value and a tolerance. The tolerance can be either expr...