Browse Source

HPCC-26011 Implement file scope to CRuntimeStatisticCollection

Signed-off-by: Shamser Ahmed <shamser.ahmed@lexisnexis.com>
Shamser Ahmed 4 years ago
parent
commit
d184d19167
3 changed files with 21 additions and 1 deletions
  1. 2 0
      system/jlib/jstatcodes.h
  2. 18 1
      system/jlib/jstats.cpp
  3. 1 0
      system/jlib/jstats.h

+ 2 - 0
system/jlib/jstatcodes.h

@@ -26,6 +26,7 @@
 #define FunctionScopePrefix "f"
 #define WorkflowScopePrefix "w"
 #define ChildGraphScopePrefix "c"
+#define FileScopePrefix "p"
 
 #define MATCHES_CONST_PREFIX(search, prefix) (strncmp(search, prefix, strlen(prefix)) == 0)
 
@@ -69,6 +70,7 @@ enum StatisticScopeType
     SSTfunction,                        // a function call
     SSTworkflow,
     SSTchildgraph,
+    SSTfile,
     SSTunknown,
     SSTmax
 };

+ 18 - 1
system/jlib/jstats.cpp

@@ -72,7 +72,7 @@ void setStatisticsComponentName(StatisticCreatorType processType, const char * p
 // Textual forms of the different enumerations, first items are for none and all.
 static constexpr const char * const measureNames[] = { "", "all", "ns", "ts", "cnt", "sz", "cpu", "skw", "node", "ppm", "ip", "cy", "en", "txt", "bool", "id", "fname", "cost", NULL };
 static constexpr const char * const creatorTypeNames[]= { "", "all", "unknown", "hthor", "roxie", "roxie:s", "thor", "thor:m", "thor:s", "eclcc", "esp", "summary", NULL };
-static constexpr const char * const scopeTypeNames[] = { "", "all", "global", "graph", "subgraph", "activity", "allocator", "section", "compile", "dfu", "edge", "function", "workflow", "child", "unknown", nullptr };
+static constexpr const char * const scopeTypeNames[] = { "", "all", "global", "graph", "subgraph", "activity", "allocator", "section", "compile", "dfu", "edge", "function", "workflow", "child", "file", "unknown", nullptr };
 
 static unsigned matchString(const char * const * names, const char * search, unsigned dft)
 {
@@ -111,6 +111,7 @@ static const StatisticScopeType scoreOrder[] = {
     SSTfunction,
     SSTworkflow,
     SSTchildgraph,
+    SSTfile,
     SSTunknown
 };
 static int scopePriority[SSTmax];
@@ -1408,6 +1409,7 @@ void StatsScopeId::describe(StringBuffer & description) const
     case SSTedge:
         description.append(' ').append(id).append(',').append(extra);
         break;
+    case SSTfile:
     case SSTfunction:
         description.append(' ').append(name);
         break;
@@ -1479,6 +1481,7 @@ void StatsScopeId::serialize(MemoryBuffer & out) const
         out.append(id);
         out.append(extra);
         break;
+    case SSTfile:
     case SSTfunction:
         out.append(name);
         break;
@@ -1554,6 +1557,15 @@ bool StatsScopeId::setScopeText(const char * text, const char * * _next)
             return true;
         }
         break;
+    case FileScopePrefix[0]:
+        if (MATCHES_CONST_PREFIX(text, FileScopePrefix))
+        {
+            setFileId(text+strlen(FileScopePrefix));
+            if (_next)
+                *_next = text + strlen(text);
+            return true;
+        }
+        break;
     case WorkflowScopePrefix[0]:
         if (MATCHES_CONST_PREFIX(text, WorkflowScopePrefix) && isdigit(text[strlen(WorkflowScopePrefix)]))
         {
@@ -1616,6 +1628,11 @@ void StatsScopeId::setFunctionId(const char * _name)
     scopeType = SSTfunction;
     name.set(_name);
 }
+void StatsScopeId::setFileId(const char * _name)
+{
+    scopeType = SSTfile;
+    name.set(_name);
+}
 void StatsScopeId::setWorkflowId(unsigned _id)
 {
     setId(SSTworkflow, _id);

+ 1 - 0
system/jlib/jstats.h

@@ -82,6 +82,7 @@ public:
     void setActivityId(unsigned _id);
     void setEdgeId(unsigned _id, unsigned _output);
     void setFunctionId(const char * _name);
+    void setFileId(const char * _name);
     void setSubgraphId(unsigned _id);
     void setWorkflowId(unsigned _id);
     void setChildGraphId(unsigned _id);