Commit ab45c171 authored by Pascal Palenda's avatar Pascal Palenda
Browse files

Clean up

parent 8d633829
......@@ -220,8 +220,6 @@ namespace ITAProfiler
std::stringstream ProfilerToJSON ( )
{
json jnRoot;
//TODO: Name should not be needed here. Test this and remove lines afterwards.
//jnRoot.set_name ( "Profiler" );
jnRoot["Time Unit"] = "us - 1e-6";
jnRoot["CPU Frequency"] = ITAClock::getDefaultClock ( )->getFrequency ( );
......@@ -229,12 +227,7 @@ namespace ITAProfiler
json jnSection;
json jnEventCount;
json jnValue;
//TODO: Check whether this was change properly (see further below). Remove afterwards.
//jnSection.set_name ( "Profile Sections" );
//jnEventCount.set_name ( "Profile EventCounts" );
//jnValue.set_name ( "Profile Values" );
// Disable profiling while we write to file.
m_bEnabled = false;
......@@ -255,8 +248,6 @@ namespace ITAProfiler
for ( const auto& sectionPair : threadStorage.second.m_mSections )
{
swSection.start ( );
//TODO: I think the node will become a json array if using push_back on an empty node.
//It would probably be better to create the name of the node in this function and use jnSection[name] = jsonNode (without a root name)
jnSection.push_back ( ProfileSectionToJSON ( sectionPair, m_mThreadNames ) );
swSection.stop ( );
}
......@@ -309,16 +300,6 @@ namespace ITAProfiler
if ( threadNameIterator != mThreadNames.end ( ) )
sThreadName = threadNameIterator->second;
json jnRootWithName;
std::string sRootName;
//TODO: The code section is almost the same in this and the two functions below: Create subfunction for reusability?
if ( !sThreadName.empty ( ) )
sRootName = "[" + eventCountPair.first.sFunction + "][" + eventCountPair.first.sName + "][" + sThreadName + "]";
else
sRootName = "[" + eventCountPair.first.sFunction + "][" + eventCountPair.first.sName + "][" +
std::to_string ( std::hash<std::thread::id> ( ) ( eventCountPair.first.iThreadId ) ) + "]";
json jnRoot;
jnRoot["Name"] = eventCountPair.first.sName;
......@@ -330,7 +311,6 @@ namespace ITAProfiler
jnRoot["Thread Name"] = sThreadName;
jnRoot["Count"] = eventCountPair.second.vTimeStamps.size ( );
//TODO: End of repeating section (see TODO above)
std::vector<double> vdTimeStamps ( eventCountPair.second.vTimeStamps.size ( ) );
......@@ -339,19 +319,6 @@ namespace ITAProfiler
vdTimeStamps.begin ( ),
[&] ( const double& time ) -> double { return time - m_dStartTime; } );
/*JSONNode jnTimeStampArray ( JSON_ARRAY );
jnTimeStampArray.set_name ( "TimeStamps" );
jnTimeStampArray.reserve ( vdTimeStamps.size ( ) );
JSONNode jnData ( JSON_NUMBER );
for ( const auto& timeStamp : vdTimeStamps )
{
jnData = timeStamp;
jnTimeStampArray.push_back ( jnData );
}
jnRoot.push_back ( jnTimeStampArray );*/
const int precision = 1 + std::ceil ( std::log10 ( ITAClock::getDefaultClock ( )->getFrequency ( ) ) );
jnRoot["Time Stamps"] = ConvertToString ( vdTimeStamps, precision, "," );
......@@ -376,14 +343,6 @@ namespace ITAProfiler
if ( threadNameIterator != mThreadNames.end ( ) )
sThreadName = threadNameIterator->second;
json jnRootWithName;
std::string sRootName;
if ( !sThreadName.empty ( ) )
sRootName = "[" + sectionPair.first.sFunction + "][" + sectionPair.first.sName + "][" + sThreadName + "]";
else
sRootName = "[" + sectionPair.first.sFunction + "][" + sectionPair.first.sName + "][" +
std::to_string ( std::hash<std::thread::id> ( ) ( sectionPair.first.iThreadId ) ) + "]";
json jnRoot;
jnRoot["Name"] = sectionPair.first.sName;
jnRoot["File Name"] = sectionPair.first.sFile;
......@@ -408,31 +367,6 @@ namespace ITAProfiler
vdEndTime.begin ( ),
[&] ( const std::pair<double, double>& interval ) -> double { return interval.second - m_dStartTime; } );
/*JSONNode jnStartTimeArray ( JSON_ARRAY );
jnStartTimeArray.set_name ( "Start Times" );
jnStartTimeArray.reserve ( vdStartTime.size ( ) );
JSONNode jnData( JSON_NUMBER );
for ( const auto& timeStamp : vdStartTime )
{
jnData = timeStamp;
jnStartTimeArray.push_back ( jnData );
}
jnRoot.push_back ( jnStartTimeArray );
JSONNode jnEndTimeArray ( JSON_ARRAY );
jnEndTimeArray.set_name ( "End Times" );
jnEndTimeArray.reserve ( vdStartTime.size ( ) );
for ( const auto& timeStamp : vdEndTime )
{
jnData = timeStamp;
jnEndTimeArray.push_back ( jnData );
}
jnRoot.push_back ( jnEndTimeArray );*/
const int precision = 1 + std::ceil ( std::log10 ( ITAClock::getDefaultClock ( )->getFrequency ( ) ) );
jnRoot["Start Times"] = ConvertToString ( vdStartTime, precision, "," );
......@@ -455,15 +389,7 @@ namespace ITAProfiler
if ( threadNameIterator != mThreadNames.end ( ) )
sThreadName = threadNameIterator->second;
json jnRootWithName;
std::string sRootName;
if ( !sThreadName.empty ( ) )
sRootName = ( "[" + valuePair.first.sFunction + "][" + valuePair.first.sName + "][" + sThreadName + "]" );
else
sRootName = "[" + valuePair.first.sFunction + "][" + valuePair.first.sName + "][" +
std::to_string ( std::hash<std::thread::id> ( ) ( valuePair.first.iThreadId ) ) + "]";
json jnRoot;
jnRoot["Name"] = "Name", valuePair.first.sName;
jnRoot["File Name"] = valuePair.first.sFile;
......@@ -474,9 +400,7 @@ namespace ITAProfiler
jnRoot["Thread Name"] = sThreadName;
jnRoot["Count"] = valuePair.second.Size ( );
//TODO: Check whether change from Tuple to Node with two subnodes worked
//std::tuple<json, json> valueNodes;
json valueNodes;
// store the tim stamps
......@@ -507,9 +431,6 @@ namespace ITAProfiler
ITA_EXCEPT_INVALID_PARAMETER ( "Unkown data type" );
}
// TODO: Check whether change from Tuple to Node with two subnodes worked
//jnRoot.push_back ( std::get<0> ( valueNodes ) );
//jnRoot.push_back ( std::get<1> ( valueNodes ) );
jnRoot.insert ( valueNodes.begin ( ), valueNodes.end() );
return jnRoot;
......@@ -525,23 +446,7 @@ namespace ITAProfiler
json ValueDataToJSON ( const ProfileValue& oProfileValue )
{
std::vector<std::pair<T, double>> dataVector = oProfileValue.GetData<T> ( m_dStartTime );
/*JSONNode jnTimeStampArray ( JSON_ARRAY );
jnTimeStampArray.set_name ( "TimeStamps" );
jnTimeStampArray.reserve ( dataVector.size ( ) );
JSONNode jnDataArray ( JSON_ARRAY );
jnDataArray.set_name ( "Data" );
jnDataArray.reserve ( dataVector.size ( ) );
JSONNode jnData ( JSON_NUMBER );
for ( const auto& data : dataVector )
{
jnData = data.first;
jnDataArray.push_back ( jnData );
jnData = data.second;
jnTimeStampArray.push_back ( jnData );
}*/
std::vector<T> vTData ( dataVector.size ( ) );
std::vector<double> vdTimeStamps ( dataVector.size ( ) );
......@@ -550,14 +455,10 @@ namespace ITAProfiler
std::transform ( dataVector.begin ( ), dataVector.end ( ), vdTimeStamps.begin ( ), [] ( const std::pair<T, double>& p ) -> double { return p.second; } );
const int precision = 1 + std::ceil ( std::log10 ( ITAClock::getDefaultClock ( )->getFrequency ( ) ) );
//TODO: Check whether this still does the correct thing!
json jnRoot;
jnRoot["Time Stamps"] = ConvertToString ( vdTimeStamps, precision, "," );
jnRoot["Data"] = ConvertToString ( vTData, 8, "," );
//json jnTimeStampArray ( "Time Stamps", ConvertToString ( vdTimeStamps, precision, "," ) );
//json jnDataArray ( "Data", ConvertToString ( vTData, 8, "," ) );
//return std::make_pair ( jnTimeStampArray, jnDataArray );
return jnRoot;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment