62 std::ostringstream strs;
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()) {
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());
95 addAttribute<double>(name,val);
99 addAttribute<int>(name,val);
103 addAttribute<bool>(name,val);
107 addAttribute<std::string>(name,val.
as_string());
111 addAttribute<std::string>(name,val);
126 ptr_->appendContentLine(i,str);
167 std::string cpuname(
"Undefined");
168 unsigned int threads = 0;
169 unsigned int cores_per_socket = 0;
170 unsigned int highest_socketid = 0;
173 std::ifstream cpuinfo(
"/proc/cpuinfo");
175 if((cpuinfo.rdstate()&cpuinfo.failbit)) std::cout<<
"Failed to open filen\n";
176 while (!cpuinfo.eof() && !(cpuinfo.rdstate()&cpuinfo.failbit)) {
177 getline (cpuinfo,line);
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());
184 highest_socketid = highest_socketid>socketid?highest_socketid:socketid;
186 if (line.find(
"cpu cores") < line.size()) {
187 cores_per_socket = atoi(line.substr(line.find(
":")+2).c_str());
193 XMLTestNode machine_config(
"MachineConfiguration");
197 machine_config.
addString(
"CPU_Name", cpuname);
198 machine_config.
addInt(
"CPU_Sockets", highest_socketid+1);
199 machine_config.
addInt(
"CPU_Cores_Per_Socket", cores_per_socket);
200 machine_config.
addInt(
"CPU_Total_HyperThreads", threads);
201 return machine_config;
208 const std::string ext_hostname)
212 bool is_new_config =
true;
217 if (std::ifstream (filename.c_str ())) {
223 memset (hostname, 0, 256);
224 if (ext_hostname.empty ()) {
225 gethostname (hostname, 255);
227 strncat (hostname, ext_hostname.c_str (), 255);
243 configuration.
getTag ().compare (
"Configuration") != 0,
244 std::runtime_error,
"Unexpected Tag \"" << configuration.
getTag ()
245 <<
"\"; only children with Tag = \"Configuration\" are allowed in a "
249 ! configuration.
hasChild (
"MachineConfiguration") ||
252 "A Configuration needs to have a child \"MachineConfiguration\" and a "
258 if (machine_configuration.hasSameElements (machine_config)) {
259 is_new_config =
false;
266 int new_test_config = -1;
267 for (
int k = 0; k < old_test.
numChildren (); ++k) {
271 ! old_test_entry.
hasChild (
"TestConfiguration") ||
272 ! new_test_entry.
hasChild (
"TestResults"),
273 std::runtime_error,
"A TestEntry needs to have a child "
274 "\"TestConfiguration\" and a child \"TestResults\".");
281 if (new_test_config < 0) {
285 bool deviation =
false;
291 for (
int old_r = 0; old_r < old_results.
numChildren (); ++old_r) {
301 if((result_entry.
getTag().find(
"Time")==0) || (result_entry.
getTag().find(
"Result")==0)) {
306 double diff = old_valtol.
value - new_valtol.value;
309 double normalization = old_valtol.
value;
310 normalization*=normalization;
312 if(normalization==0?diff>0:diff/normalization>old_valtol.
tolerance*old_valtol.
tolerance) {
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;
321 if( (old_valtol.
lower>new_valtol.value) || (old_valtol.
upper<new_valtol.value)) {
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;
332 if(oldv_str.compare(new_results.
getChild(result_entry.
getTag()).getContentLine(0))!=0) {
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;
353 for(
int new_r = 0; new_r < new_results.
numChildren() ; new_r++) {
401 std::ofstream fout(filename.c_str());
402 fout << database << std::endl;
const std::string & getTag() const
Return the tag of the current node.
XMLTestNode getChild(const std::string &name) const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
void addChild(const XMLObject &child)
Add a child node to the node.
void addDouble(const std::string &name, double val)
bool hasChild(const std::string &name) const
bool isEmpty() const
Find out if a node is empty.
ValueTolerance is a struct to keep a tuple of value and a tolerance. The tolerance can be either expr...
void addValueTolerance(const std::string &name, ValueTolerance val)
Tools for an XML-based performance test archive.
void addInt(const std::string &name, int val)
RCP< XMLObjectImplem > ptr_
Representation of an XML data tree. XMLObject is a ref-counted handle to a XMLObjectImplem object...
void appendContentLine(const size_t &i, const std::string &str)
#define TEUCHOS_COMPILER_NAME
void from_string(const std::string &valtol_str)
PerfTestResult
ReturnValues for PerfTest_CheckOrAdd_Test.
int numChildren() const
Return the number of child nodes owned by this node.
void addBool(const std::string &name, bool val)
Subclass of XMLObject used by the performance archive.
void addString(const std::string &name, std::string val)
int numContentLines() const
Return the number of lines of character content stored in this node.
bool hasSameElements(XMLTestNode const &lhs) const
The XMLObjectImplem class takes care of the low-level implementation details of XMLObject.
bool operator==(ValueTolerance &rhs)
const XMLObject & getChild(int i) const
Return the i-th child node.
const std::string & getContentLine(int i) const
Return the i-th line of character content stored in this node.
const XMLObject * xml_object() const
#define TEUCHOS_COMPILER_VERSION
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.
XMLTestNode PerfTest_MachineConfig()
PerfTest_MachineConfig generates a basic machine configuration XMLTestNode.
An object representation of a subset of XML data.