namespace
{
- static Standard_CString Message_Table_PrintMetricTypeEnum[10] =
+ static Standard_CString Message_Table_PrintMetricTypeEnum[13] =
{
- "NONE", "UserTimeCPU", "SystemTimeInfo", "MemPrivate", "MemVirtual",
+ "NONE", "UserThreadCPU", "SystemThreadCPU", "UserTimeCPU", "SystemTimeCPU",
+ "WallClock", "MemPrivate", "MemVirtual",
"MemWorkingSet", "MemWorkingSetPeak", "MemSwapUsage", "MemSwapUsagePeak", "MemHeapUsage"
};
}
#include <Message.hxx>
#include <Message_Report.hxx>
#include <OSD_Chronometer.hxx>
+#include <OSD_Timer.hxx>
#include <Precision.hxx>
#include <Standard_Dump.hxx>
const NCollection_IndexedMap<Message_MetricType>& anActiveMetrics = aReport->ActiveMetrics();
// time metrics
+ if (anActiveMetrics.Contains (Message_MetricType_WallClock))
+ {
+ OSD_Timer aTimer;
+ aTimer.Start();
+ Standard_Real aTime = aTimer.StartTime();
+ if (theStartValue)
+ aMeterAttribute->SetStartValue (Message_MetricType_WallClock, aTime);
+ else
+ aMeterAttribute->SetStopValue (Message_MetricType_WallClock, aTime);
+ }
if (anActiveMetrics.Contains (Message_MetricType_ProcessCPUUserTime) ||
anActiveMetrics.Contains (Message_MetricType_ProcessCPUSystemTime) ||
anActiveMetrics.Contains (Message_MetricType_ThreadCPUUserTime) ||
for (NCollection_IndexedDataMap<Message_MetricType, StartToStopValue>::Iterator anIterator (myMetrics);
anIterator.More(); anIterator.Next())
{
- Message_MetricType aMetricType = anIterator.Key();
- OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, aMetricType)
-
- Standard_Real aStartValue = anIterator.Value().first;
- OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, aStartValue)
-
- Standard_Real aStopValue = anIterator.Value().second;
- OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, aStopValue)
+ OCCT_DUMP_VECTOR_CLASS (theOStream, Message::MetricToString (anIterator.Key()),
+ 2, anIterator.Value().first, anIterator.Value().second)
}
}
OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Message_Attribute)
- TCollection_AsciiString aStream = Standard_Dump::Text (myStream);
- OCCT_DUMP_FIELD_VALUE_STRING (theOStream, aStream)
+ OCCT_DUMP_STREAM_VALUE_DUMPED (theOStream, myStream)
}
for (unsigned int i = 0; i < sizeof(myAlerts)/sizeof(myAlerts[0]); ++i)
{
+ if (myAlerts[i].IsEmpty())
+ continue;
+
Message_Gravity aGravity = (Message_Gravity)i;
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, aGravity)
- for (Message_ListOfAlert::Iterator anIt (myAlerts[i]); anIt.More(); anIt.Next())
+ Standard_Integer anInc = 1;
+ for (Message_ListOfAlert::Iterator anIt (myAlerts[i]); anIt.More(); anIt.Next(), anInc++)
{
const Handle(Message_Alert)& anAlert = anIt.Value();
- OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, anAlert.get())
+ OCCT_DUMP_FIELD_VALUES_DUMPED_INC (theOStream, theDepth, anAlert.get(), anInc)
}
}
}
Message_MetricType_ThreadCPUSystemTime, //!< OSD_Chronometer::GetThreadCPU system time
Message_MetricType_ProcessCPUUserTime, //!< OSD_Chronometer::GetProcessCPU user time
Message_MetricType_ProcessCPUSystemTime, //!< OSD_Chronometer::GetProcessCPU system time
+ Message_MetricType_WallClock, //!< OSD_Timer elapsed time
Message_MetricType_MemPrivate, //!< OSD_MemInfo::MemPrivate
Message_MetricType_MemVirtual, //!< OSD_MemInfo::MemVirtual
Message_MetricType_MemWorkingSet, //!< OSD_MemInfo::MemWorkingSet
//! the Timer.
Standard_EXPORT virtual void Start() Standard_OVERRIDE;
+ //! Returns start time in seconds.
+ Standard_Real StartTime() const { return myTimeStart; }
+
//! Returns elapsed time in seconds.
Standard_EXPORT Standard_Real ElapsedTime() const;
{
OCCT_DUMP_CLASS_BEGIN (theOStream, Select3D_SensitiveEntity);
- OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myOwnerId.get());
+ OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myOwnerId.get())
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, mySFactor);
}
{
OCCT_DUMP_CLASS_BEGIN (theOStream, SelectMgr_Selection);
+ NCollection_IndexedMap<Handle(SelectMgr_EntityOwner)> anOwners;
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator anIterator (myEntities); anIterator.More(); anIterator.Next())
+ {
+ const Handle(SelectMgr_SensitiveEntity)& anEntity = anIterator.Value();
+ if (anEntity.IsNull() || anEntity->BaseSensitive().IsNull())
+ {
+ continue;
+ }
+ const Handle(SelectMgr_EntityOwner)& anOwner = anEntity->BaseSensitive()->OwnerId();
+ if (!anOwners.Contains (anOwner))
+ {
+ anOwners.Add (anOwner);
+ }
+ }
+
+ for (NCollection_IndexedMap<Handle(SelectMgr_EntityOwner)>::Iterator anIterator (anOwners); anIterator.More(); anIterator.Next())
+ {
+ const Handle(SelectMgr_EntityOwner)& anOwner = anIterator.Value();
+ OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, anOwner.get())
+ }
+
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator anIterator (myEntities); anIterator.More(); anIterator.Next())
{
Handle(SelectMgr_SensitiveEntity) anEntity = anIterator.Value();
Standard_SStream aStream;
aStream << theOStream.rdbuf();
TCollection_AsciiString aStreamStr = Standard_Dump::Text (aStream);
- if (!aStreamStr.IsEmpty() && !aStreamStr.EndsWith ("{"))
+ if (!aStreamStr.IsEmpty() && !aStreamStr.EndsWith ("{") && !aStreamStr.EndsWith (", "))
theOStream << ", ";
}
aName.Remove (1, 1);
}
- if (::LowerCase (aName.Value(1)) == 'm' && aName.Value (2) == 'y')
+ if (aName.Length() > 1 && aName.Value (1) == 'a')
+ {
+ if (aName.Length() > 2 && aName.Value (2) == 'n')
+ {
+ aName.Remove (1, 2);
+ }
+ else
+ aName.Remove (1, 1);
+ }
+ else if (aName.Length() > 2 && ::LowerCase (aName.Value (1)) == 'm' && aName.Value (2) == 'y')
{
aName.Remove (1, 2);
}
-
- if (TCollection_AsciiString (aName).EndsWith (".get()"))
+
+ if (aName.EndsWith (".get()"))
{
aName = aName.SubString (1, aName.Length() - TCollection_AsciiString (".get()").Length());
}
- else if (TCollection_AsciiString (aName).EndsWith ("()"))
+ else if (aName.EndsWith ("()"))
{
aName = aName.SubString (1, aName.Length() - TCollection_AsciiString ("()").Length());
}
Standard_Integer anIndentCount = 0;
Standard_Boolean isMassiveValues = Standard_False;
- for (Standard_Integer anIndex = 1; anIndex < aStreamStr.Length(); anIndex++)
+ for (Standard_Integer anIndex = 1; anIndex <= aStreamStr.Length(); anIndex++)
{
Standard_Character aSymbol = aStreamStr.Value (anIndex);
+ if (anIndex == 1 && aText.IsEmpty() && aSymbol != '{')
+ {
+ // append opening brace for json start
+ aSymbol = '{';
+ anIndex--;
+ }
if (aSymbol == '{')
{
anIndentCount++;
}
else
aText += aSymbol;
+
+ if (anIndex == aStreamStr.Length() && aSymbol != '}')
+ {
+ // append closing brace for json end
+ aSymbol = '}';
+
+ anIndentCount--;
+ aText += '\n';
+ for (int anIndent = 0; anIndent < anIndentCount; anIndent++)
+ aText += anIndentStr;
+ aText += aSymbol;
+ }
}
return aText;
}
} \
}
+//! @def OCCT_DUMP_FIELD_VALUES_DUMPED
+//! Append into output value: "Name": { field dumped values }
+//! It computes Dump of the fields. The expected field is a pointer.
+//! Use this macro for fields of the dumped class which has own Dump implementation.
+//! The macros is recursive. Recursion is stopped when the depth value becomes equal to zero.
+//! Depth = -1 is the default value, dump here is unlimited.
+#define OCCT_DUMP_FIELD_VALUES_DUMPED_INC(theOStream, theDepth, theField, theIncName) \
+{ \
+ if (theDepth != 0 && (void*)(theField) != NULL) \
+ { \
+ Standard_SStream aFieldStream; \
+ (theField)->DumpJson (aFieldStream, theDepth - 1); \
+ TCollection_AsciiString aName = Standard_Dump::DumpFieldToName (#theField) + theIncName; \
+ Standard_Dump::DumpKeyToClass (theOStream, aName, Standard_Dump::Text (aFieldStream)); \
+ } \
+}
+
+//! @def OCCT_DUMP_FIELD_VALUES_DUMPED
+//! Append into output value: "Name": { field dumped values }
+//! It computes Dump of the fields. The expected field is a pointer.
+//! Use this macro for fields of the dumped class which has own Dump implementation.
+//! The macros is recursive. Recursion is stopped when the depth value becomes equal to zero.
+//! Depth = -1 is the default value, dump here is unlimited.
+#define OCCT_DUMP_STREAM_VALUE_DUMPED(theOStream, theField) \
+{ \
+ TCollection_AsciiString aName = Standard_Dump::DumpFieldToName (#theField); \
+ Standard_Dump::DumpKeyToClass (theOStream, aName, Standard_Dump::Text (theField)); \
+}
+
//! @def OCCT_INIT_FIELD_VALUES_DUMPED
//! Append into output value: "Name": { field dumped values }
//! It computes Dump of the fields. The expected field is a pointer.
#define OCCT_DUMP_VECTOR_CLASS(theOStream, theName, theCount, ...) \
{ \
Standard_Dump::AddValuesSeparator (theOStream); \
- theOStream << "\"" << OCCT_CLASS_NAME(theName) << "\": ["; \
+ theOStream << "\"" << theName << "\": ["; \
Standard_Dump::DumpRealValues (theOStream, theCount, __VA_ARGS__);\
theOStream << "]"; \
}
//! - for '{' append after '\n' and indent to the next value, increment current indent value
//! - for '}' append '\n' and current indent before it, decrement indent value
//! - for ',' append after '\n' and indent to the next value. If the current symbol is in massive container [], do nothing
+ //! Covers result with opened and closed brackets on the top level, if it has no symbols there.
//! @param theStream source value
//! @param theIndent count of ' ' symbols to apply hierarchical indent of the text values
//! @return text presentation
void gp_Ax1::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const
{
- OCCT_DUMP_VECTOR_CLASS (theOStream, Location, 3, loc.X(), loc.Y(), loc.Z())
- OCCT_DUMP_VECTOR_CLASS (theOStream, Direction, 3, vdir.X(), vdir.Y(), vdir.Z())
+ OCCT_DUMP_VECTOR_CLASS (theOStream, "Location", 3, loc.X(), loc.Y(), loc.Z())
+ OCCT_DUMP_VECTOR_CLASS (theOStream, "Direction", 3, vdir.X(), vdir.Y(), vdir.Z())
}
Standard_Boolean gp_Ax1::InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos)
void gp_Ax2::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const
{
- OCCT_DUMP_VECTOR_CLASS (theOStream, Location, 3, axis.Location().X(), axis.Location().Y(), axis.Location().Z())
- OCCT_DUMP_VECTOR_CLASS (theOStream, Direction, 3, axis.Direction().X(), axis.Direction().Y(), axis.Direction().Z())
+ OCCT_DUMP_VECTOR_CLASS (theOStream, "Location", 3, axis.Location().X(), axis.Location().Y(), axis.Location().Z())
+ OCCT_DUMP_VECTOR_CLASS (theOStream, "Direction", 3, axis.Direction().X(), axis.Direction().Y(), axis.Direction().Z())
- OCCT_DUMP_VECTOR_CLASS (theOStream, XDirection, 3, vxdir.X(), vxdir.Y(), vxdir.Z())
- OCCT_DUMP_VECTOR_CLASS (theOStream, YDirection, 3, vydir.X(), vydir.Y(), vydir.Z())
+ OCCT_DUMP_VECTOR_CLASS (theOStream, "XDirection", 3, vxdir.X(), vxdir.Y(), vxdir.Z())
+ OCCT_DUMP_VECTOR_CLASS (theOStream, "YDirection", 3, vydir.X(), vydir.Y(), vydir.Z())
}
Standard_Boolean gp_Ax2::InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos)
void gp_Ax3::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const
{
- OCCT_DUMP_VECTOR_CLASS (theOStream, Location, 3, Location().X(), Location().Y(), Location().Z())
- OCCT_DUMP_VECTOR_CLASS (theOStream, Direction, 3, Direction().X(), Direction().Y(), Direction().Z())
+ OCCT_DUMP_VECTOR_CLASS (theOStream, "Location", 3, Location().X(), Location().Y(), Location().Z())
+ OCCT_DUMP_VECTOR_CLASS (theOStream, "Direction", 3, Direction().X(), Direction().Y(), Direction().Z())
- OCCT_DUMP_VECTOR_CLASS (theOStream, XDirection, 3, XDirection().X(), XDirection().Y(), XDirection().Z())
- OCCT_DUMP_VECTOR_CLASS (theOStream, YDirection, 3, YDirection().X(), YDirection().Y(), YDirection().Z())
+ OCCT_DUMP_VECTOR_CLASS (theOStream, "XDirection", 3, XDirection().X(), XDirection().Y(), XDirection().Z())
+ OCCT_DUMP_VECTOR_CLASS (theOStream, "YDirection", 3, YDirection().X(), YDirection().Y(), YDirection().Z())
}
Standard_Boolean gp_Ax3::InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos)
void gp_Dir::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const
{
- OCCT_DUMP_VECTOR_CLASS (theOStream, gp_Dir, 3, coord.X(), coord.Y(), coord.Z())
+ OCCT_DUMP_VECTOR_CLASS (theOStream, "gp_Dir", 3, coord.X(), coord.Y(), coord.Z())
}
Standard_Boolean gp_Dir::InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos)
//=======================================================================
void gp_Mat::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const
{
- OCCT_DUMP_VECTOR_CLASS (theOStream, gp_Mat, 9, Mat00, Mat01, Mat02, Mat10, Mat11, Mat12, Mat20, Mat21, Mat22);
+ OCCT_DUMP_VECTOR_CLASS (theOStream, "gp_Mat", 9, Mat00, Mat01, Mat02, Mat10, Mat11, Mat12, Mat20, Mat21, Mat22);
}
void gp_Pnt::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const
{
- OCCT_DUMP_VECTOR_CLASS (theOStream, gp_Pnt, 3, coord.X(), coord.Y(), coord.Z())
+ OCCT_DUMP_VECTOR_CLASS (theOStream, "gp_Pnt", 3, coord.X(), coord.Y(), coord.Z())
}
Standard_Boolean gp_Pnt::InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos)
//=======================================================================
void gp_Trsf::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const
{
- OCCT_DUMP_VECTOR_CLASS (theOStream, Location, 3, loc.X(), loc.Y(), loc.Z())
- OCCT_DUMP_VECTOR_CLASS (theOStream, Matrix, 9, matrix.Value(1, 1), matrix.Value(1, 2), matrix.Value(1, 3),
+ OCCT_DUMP_VECTOR_CLASS (theOStream, "Location", 3, loc.X(), loc.Y(), loc.Z())
+ OCCT_DUMP_VECTOR_CLASS (theOStream, "Matrix", 9, matrix.Value(1, 1), matrix.Value(1, 2), matrix.Value(1, 3),
matrix.Value(2, 1), matrix.Value(2, 2), matrix.Value(2, 3),
matrix.Value(3, 1), matrix.Value(3, 2), matrix.Value(3, 3))
//=======================================================================
void gp_XYZ::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const
{
- OCCT_DUMP_VECTOR_CLASS (theOStream, gp_XYZ, 3, x, y, z)
+ OCCT_DUMP_VECTOR_CLASS (theOStream, "gp_XYZ", 3, x, y, z)
}
//=======================================================================