Skip to content

Commit

Permalink
[Janitor mode] Fix whitespace
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@22291 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
OpenModelica-Hudson committed Sep 12, 2014
1 parent 84a82e4 commit 7f2db9f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion Compiler/Template/CodegenCpp.tpl
Expand Up @@ -1289,7 +1289,7 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__)) then
std::pair<boost::shared_ptr<IMixedSystem>,boost::shared_ptr<ISimData> > system = simulation.first->LoadSystem("OMCpp<%fileNamePrefix%><%makefileParams.dllext%>","<%lastIdentOfPath(modelInfo.name)%>");
simulation.first->Start(system.first,simulation.second,"<%lastIdentOfPath(modelInfo.name)%>");
<%if boolNot(stringEq(getConfigString(PROFILING_LEVEL),"none")) then
<<
MeasureTime::getInstance()->writeToJson();
Expand Down
84 changes: 42 additions & 42 deletions SimulationRuntime/cpp/Core/Utils/extension/measure_time.cpp
Expand Up @@ -20,9 +20,9 @@ MeasureTimeData::~MeasureTimeData()

std::string MeasureTimeData::serializeToJson() const
{
std::stringstream ss("");
ss << "\"ncall\":" << numCalcs << "," << sumMeasuredValues->serializeToJson();
return ss.str();
std::stringstream ss("");
ss << "\"ncall\":" << numCalcs << "," << sumMeasuredValues->serializeToJson();
return ss.str();
}

MeasureTime::MeasureTime() : overhead(NULL) {}
Expand All @@ -40,7 +40,7 @@ MeasureTime* MeasureTime::getInstance()

void MeasureTime::deinitialize()
{
std::cerr << "Deinit:" << std::endl;
std::cerr << "Deinit:" << std::endl;
if (instance != 0)
{
std::cerr << "try is " << std::endl;
Expand Down Expand Up @@ -96,50 +96,50 @@ void MeasureTime::benchOverhead()

void MeasureTime::addJsonContentBlock(const std::string model_name, const std::string blockname, const std::vector<MeasureTimeData> * in)
{
toWrite[model_name][blockname] = in;
toWrite[model_name][blockname] = in;
}

void MeasureTime::writeToJson()
{
std::stringstream date;
date.str("");
time_t sec = time(NULL);
tm * date_t = localtime(&sec);
date << date_t->tm_year + 1900 << "-" << date_t->tm_mon + 1 << "-" << date_t->tm_mday << " " << date_t->tm_hour << ":" << date_t->tm_min << ":" << date_t->tm_sec;
date.str("");
time_t sec = time(NULL);
tm * date_t = localtime(&sec);
date << date_t->tm_year + 1900 << "-" << date_t->tm_mon + 1 << "-" << date_t->tm_mday << " " << date_t->tm_hour << ":" << date_t->tm_min << ":" << date_t->tm_sec;

for( file_map::const_iterator model = toWrite.begin() ; model != toWrite.end() ; ++model ) // iterate files
{
std::ofstream os;
os.open((model->first + std::string("_prof.json")).c_str());
os << "{\n\"name\":\"" << model->first << "\",\n";
os << "\"prefix\":\"" << model->first << "\",\n";
os << "\"date\":\"" << date.str() << "\",\n";

//write blocks:
bool isFirstBlock = true;
for( block_map::const_iterator block = model->second.begin() ; block != model->second.end() ; ++block ) // iterate blocks
{
const std::vector<MeasureTimeData> * data = block->second;

if(isFirstBlock) isFirstBlock = false;
else
{
os << ",\n";
}
os << "\"" << block->first << "\":[\n";
//write data
for (unsigned i = 0; i < data->size()-1; ++i)
{
os << "{\"id\":" << i+1 << "," << (*data)[i].serializeToJson() << "},\n";
}
if( data->size() > 0 ) os << "{\"id\":" << data->size() << "," << (*data)[data->size()-1].serializeToJson() << "}]";
else os << "]";

} // end blocks

os << "\n}";
os.close();

} // end files
std::ofstream os;
os.open((model->first + std::string("_prof.json")).c_str());
os << "{\n\"name\":\"" << model->first << "\",\n";
os << "\"prefix\":\"" << model->first << "\",\n";
os << "\"date\":\"" << date.str() << "\",\n";

//write blocks:
bool isFirstBlock = true;
for( block_map::const_iterator block = model->second.begin() ; block != model->second.end() ; ++block ) // iterate blocks
{
const std::vector<MeasureTimeData> * data = block->second;

if(isFirstBlock) isFirstBlock = false;
else
{
os << ",\n";
}
os << "\"" << block->first << "\":[\n";

//write data
for (unsigned i = 0; i < data->size()-1; ++i)
{
os << "{\"id\":" << i+1 << "," << (*data)[i].serializeToJson() << "},\n";
}
if( data->size() > 0 ) os << "{\"id\":" << data->size() << "," << (*data)[data->size()-1].serializeToJson() << "}]";
else os << "]";

} // end blocks

os << "\n}";
os.close();

} // end files
}
Expand Up @@ -4,7 +4,7 @@ MeasureTimeValuesRDTSC::MeasureTimeValuesRDTSC(unsigned long long time) : Measur

MeasureTimeValuesRDTSC::~MeasureTimeValuesRDTSC() {}

std::string MeasureTimeValuesRDTSC::serializeToJson() const
std::string MeasureTimeValuesRDTSC::serializeToJson() const
{
std::stringstream ss;
ss << "\"time\":" << time << ",\"maxTime\":" << max_time;
Expand Down Expand Up @@ -43,8 +43,8 @@ void MeasureTimeValuesRDTSC::add(MeasureTimeValues *values)
MeasureTimeValuesRDTSC *val = static_cast<MeasureTimeValuesRDTSC*>(values);
time += val->time;

if( val->time > max_time )
max_time = val->time;
if( val->time > max_time )
max_time = val->time;
}

void MeasureTimeValuesRDTSC::sub(MeasureTimeValues *values)
Expand Down

0 comments on commit 7f2db9f

Please sign in to comment.