Remove the C4251 warning elements from sc_benchmark.h, adjust code.
This commit is contained in:
+19
-13
@@ -13,6 +13,7 @@
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
@@ -83,8 +84,7 @@ benchVals getMemAndTime()
|
||||
|
||||
// --------------------- benchmark class ---------------------
|
||||
|
||||
benchmark::benchmark(std::string description, bool debugMessages, std::ostream &o_stream): ostr(o_stream),
|
||||
descr(description), debug(debugMessages), stopped(false)
|
||||
benchmark::benchmark(bool debugMessages): debug(debugMessages), stopped(false)
|
||||
{
|
||||
initialVals = getMemAndTime();
|
||||
}
|
||||
@@ -94,10 +94,14 @@ benchmark::~benchmark()
|
||||
if(!stopped) {
|
||||
stop();
|
||||
if(debug) {
|
||||
ostr << "benchmark::~benchmark(): stop was not called before destructor!" << std::endl;
|
||||
std::cerr << "benchmark::~benchmark(): stop was not called before destructor!" << std::endl;
|
||||
}
|
||||
out();
|
||||
}
|
||||
if (benchVals_str) {
|
||||
free((void *)benchVals_str);
|
||||
benchVals_str = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void benchmark::stop()
|
||||
@@ -129,32 +133,34 @@ benchVals benchmark::get()
|
||||
return delta;
|
||||
}
|
||||
|
||||
void benchmark::reset(std::string description)
|
||||
{
|
||||
descr = description;
|
||||
reset();
|
||||
}
|
||||
void benchmark::reset()
|
||||
{
|
||||
stopped = false;
|
||||
initialVals = getMemAndTime();
|
||||
}
|
||||
|
||||
std::string benchmark::str()
|
||||
const char *benchmark::str()
|
||||
{
|
||||
return str(get());
|
||||
}
|
||||
|
||||
void benchmark::out()
|
||||
{
|
||||
ostr << str() << std::endl;
|
||||
std::cout << str() << std::endl;
|
||||
}
|
||||
|
||||
std::string benchmark::str(const benchVals &bv)
|
||||
const char *benchmark::str(const benchVals &bv)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << descr << " Physical memory: " << bv.physMemKB << "kb; Virtual memory: " << bv.virtMemKB;
|
||||
ss << " Physical memory: " << bv.physMemKB << "kb; Virtual memory: " << bv.virtMemKB;
|
||||
ss << "kb; User CPU time: " << bv.userMilliseconds << "ms; System CPU time: " << bv.sysMilliseconds << "ms";
|
||||
return ss.str();
|
||||
if (benchVals_str) {
|
||||
free((void *)benchVals_str);
|
||||
benchVals_str = NULL;
|
||||
}
|
||||
benchVals_str = (char *)calloc(ss.str().length() + 1, sizeof(char));
|
||||
snprintf(benchVals_str, ss.str().length(), "%s", ss.str().c_str());
|
||||
benchVals_str[ss.str().length()] = '\0';
|
||||
return benchVals_str;
|
||||
}
|
||||
|
||||
|
||||
+5
-15
@@ -5,9 +5,7 @@
|
||||
#include "sc_export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <iostream>
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
|
||||
#include "sc_memmgr.h"
|
||||
extern "C" {
|
||||
@@ -43,34 +41,26 @@ class SC_BASE_EXPORT benchmark
|
||||
{
|
||||
protected:
|
||||
benchVals initialVals, laterVals;
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable: 4251 )
|
||||
#endif
|
||||
std::ostream &ostr;
|
||||
std::string descr;
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
bool debug, stopped;
|
||||
char *benchVals_str = NULL;
|
||||
|
||||
public:
|
||||
benchmark(std::string description = "", bool debugMessages = true, std::ostream &o_stream = std::cout);
|
||||
benchmark(bool debugMessages = true);
|
||||
|
||||
/// if 'stopped' is false, uses str(true) to print to ostream
|
||||
~benchmark();
|
||||
void reset();
|
||||
void reset(std::string description);
|
||||
benchVals get();
|
||||
void stop();
|
||||
|
||||
/// converts data member 'laterVals' into a string and returns it
|
||||
std::string str();
|
||||
const char *str();
|
||||
|
||||
/// outputs result of str() on ostream 'ostr'
|
||||
void out();
|
||||
|
||||
/// converts 'bv' into a string, prefixed by data member 'descr'
|
||||
std::string str(const benchVals &bv);
|
||||
const char *str(const benchVals &bv);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "lazyInstMgr.h"
|
||||
#include <sc_benchmark.h>
|
||||
#include "SdaiSchemaInit.h"
|
||||
#include "sc_memmgr.h"
|
||||
#include "sc_benchmark.h"
|
||||
#include <sc_cf.h>
|
||||
|
||||
#ifndef NO_REGISTRY
|
||||
@@ -148,13 +150,15 @@ int main(int argc, char **argv)
|
||||
#endif //NO_REGISTRY
|
||||
|
||||
instanceID instWithRef;
|
||||
benchmark stats("================ p21 lazy load: scanning the file ================\n");
|
||||
benchmark stats;
|
||||
std::cout << "================ p21 lazy load: scanning the file ================\n";
|
||||
mgr->openFile(argv[1]);
|
||||
stats.stop();
|
||||
benchVals scanStats = stats.get();
|
||||
stats.out();
|
||||
|
||||
stats.reset("================ p21 lazy load: gathering statistics ================\n");
|
||||
std::cout << "================ p21 lazy load: gathering statistics ================\n";
|
||||
stats.reset();
|
||||
|
||||
int instances = mgr->totalInstanceCount();
|
||||
std::cout << "Total instances: " << instances << " (" << (float)(scanStats.userMilliseconds * 1000) / instances << "us per instance, ";
|
||||
@@ -197,7 +201,8 @@ int main(int argc, char **argv)
|
||||
#endif //NO_REGISTRY
|
||||
|
||||
stats.out();
|
||||
stats.reset("================ p21 lazy load: freeing memory ================\n");
|
||||
std::cout << "================ p21 lazy load: freeing memory ================\n";
|
||||
stats.reset();
|
||||
delete mgr;
|
||||
//stats will print from its destructor
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
*/
|
||||
|
||||
extern void SchemaInit(class Registry &);
|
||||
#include "sc_version_string.h"
|
||||
#include <STEPfile.h>
|
||||
#include <sdai.h>
|
||||
#include <STEPattribute.h>
|
||||
@@ -94,7 +93,7 @@ void checkSchemaName(Registry ®, STEPfile &sf, bool ignoreErr)
|
||||
|
||||
void printVersion(const char *exe)
|
||||
{
|
||||
std::cout << exe << " build info: " << sc_version << std::endl;
|
||||
std::cout << exe << " build info: " << SC_VERSION << std::endl;
|
||||
}
|
||||
|
||||
void printUse(const char *exe)
|
||||
@@ -155,7 +154,8 @@ int main(int argc, char *argv[])
|
||||
STEPfile sfile(registry, instance_list, "", strict);
|
||||
char *flnm;
|
||||
|
||||
benchmark stats("p21 ReadExchangeFile()");
|
||||
// p21 ReadExchangeFile()
|
||||
benchmark stats();
|
||||
|
||||
cout << argv[0] << ": load file ..." << endl;
|
||||
if(argc >= (sc_optind + 1)) {
|
||||
|
||||
Reference in New Issue
Block a user