示例#1
0
        public void SetMetricsReportingStmtEnabled(String statementName)
        {
            StatementMetricHandle handle = _statementMetricHandles.Get(statementName);

            if (handle == null)
            {
                throw new ConfigurationException("Statement by name '" + statementName + "' not found in metrics collection");
            }
            handle.IsEnabled = true;
        }
示例#2
0
        public StatementMetricHandle GetStatementHandle(String statementId, String statementName)
        {
            if (!MetricReportingPath.IsMetricsEnabled)
            {
                return(null);
            }

            StatementMetricHandle handle = _stmtMetricRepository.AddStatement(statementName);

            _statementMetricHandles.Put(statementName, handle);
            return(handle);
        }
示例#3
0
        /// <summary>Account row output. </summary>
        /// <param name="handle">statement handle</param>
        /// <param name="numIStream">num rows insert stream</param>
        /// <param name="numRStream">num rows remove stream</param>
        public void AccountOutput(StatementMetricHandle handle,
                                  int numIStream,
                                  int numRStream)
        {
            StatementMetricArray array = _groupMetrics[handle.GroupNum];

            using (array.RWLock.AcquireReadLock())
            {
                StatementMetric metric = array.GetAddMetric(handle.Index);
                metric.AddNumOutputIStream(numIStream);
                metric.AddNumOutputRStream(numRStream);
            }
        }
        /// <summary>
        /// Calls the specified observable call.
        /// </summary>
        /// <param name="statementMetricHandle">The statement metric handle.</param>
        /// <param name="perfCollector">The perf collector.</param>
        /// <param name="observableCall">The observable call.</param>
        /// <param name="numInput">The num input.</param>
        public static void Call(this StatementMetricHandle statementMetricHandle, PerformanceCollector perfCollector, Action observableCall, int numInput = 1)
        {
            if ((MetricReportingPath.IsMetricsEnabled) && statementMetricHandle.IsEnabled)
            {
#if MONO
                long lCreationTime, lExitTime;
                long lUserTimeA, lKernelTimeA;
                long lUserTimeB, lKernelTimeB;
                //IntPtr thread = GetCurrentThread();
                long lWallTimeA = PerformanceObserverMono.NanoTime;

                //GetThreadTimes(out lUserTimeA, out lKernelTimeA);
                observableCall.Invoke();
                //GetThreadTimes(out lUserTimeB, out lKernelTimeB);

                long lWallTimeB = PerformanceObserverMono.NanoTime;
                long lTimeA     = 0; // lKernelTimeA + lUserTimeA
                long lTimeB     = 0; // lKernelTimeB + lUserTimeB

                perfCollector.Invoke(
                    metricValue,
                    100 * (lTimeB - lTimeA),
                    lWallTimeB - lWallTimeA);
#else
                long   lCreationTime, lExitTime;
                long   lUserTimeA, lKernelTimeA;
                long   lUserTimeB, lKernelTimeB;
                IntPtr thread     = GetCurrentThread();
                long   lWallTimeA = PerformanceObserverMono.NanoTime;

                GetThreadTimes(thread, out lCreationTime, out lExitTime, out lUserTimeA, out lKernelTimeA);
                observableCall.Invoke();
                GetThreadTimes(thread, out lCreationTime, out lExitTime, out lUserTimeB, out lKernelTimeB);

                long lWallTimeB = PerformanceObserverMono.NanoTime;
                long lTimeA     = (lKernelTimeA + lUserTimeA);
                long lTimeB     = (lKernelTimeB + lUserTimeB);

                perfCollector.Invoke(
                    statementMetricHandle,
                    100 * (lTimeB - lTimeA),
                    lWallTimeB - lWallTimeA,
                    numInput);
#endif
            }
            else
            {
                observableCall.Invoke();
            }
        }
示例#5
0
        /// <summary>
        /// Account statement times.
        /// </summary>
        /// <param name="handle">statement handle</param>
        /// <param name="cpu">time</param>
        /// <param name="wall">time</param>
        /// <param name="numInput">The num input.</param>
        public void AccountTimes(StatementMetricHandle handle,
                                 long cpu,
                                 long wall,
                                 int numInput)
        {
            StatementMetricArray array = _groupMetrics[handle.GroupNum];

            using (array.RWLock.AcquireReadLock())
            {
                StatementMetric metric = array.GetAddMetric(handle.Index);
                metric.IncrementTime(cpu, wall);
                metric.AddNumInput(numInput);
            }
        }
示例#6
0
 public void AccountOutput(StatementMetricHandle handle, int numIStream, int numRStream)
 {
     _stmtMetricRepository.AccountOutput(handle, numIStream, numRStream);
 }
示例#7
0
 public void AccountTime(StatementMetricHandle metricsHandle, long deltaCPU, long deltaWall, int numInputEvents)
 {
     _stmtMetricRepository.AccountTimes(metricsHandle, deltaCPU, deltaWall, numInputEvents);
 }
示例#8
0
        /// <summary>
        /// Calls the specified observable call.
        /// </summary>
        /// <param name="statementMetricHandle">The statement metric handle.</param>
        /// <param name="perfCollector">The perf collector.</param>
        /// <param name="observableCall">The observable call.</param>
        /// <param name="numInput">The num input.</param>
        public static void Call(this StatementMetricHandle statementMetricHandle, PerformanceCollector perfCollector, Action observableCall, int numInput = 1)
        {
            if ((MetricReportingPath.IsMetricsEnabled) && statementMetricHandle.IsEnabled)
            {
#if MONO
                long lCreationTime, lExitTime;
                long lUserTimeA, lKernelTimeA;
                long lUserTimeB, lKernelTimeB;
                //IntPtr thread = GetCurrentThread();
                long lWallTimeA = PerformanceObserverMono.NanoTime;

                //GetThreadTimes(out lUserTimeA, out lKernelTimeA);
                observableCall.Invoke();
                //GetThreadTimes(out lUserTimeB, out lKernelTimeB);

                long lWallTimeB = PerformanceObserverMono.NanoTime;
                long lTimeA     = 0; // lKernelTimeA + lUserTimeA
                long lTimeB     = 0; // lKernelTimeB + lUserTimeB

                perfCollector.Invoke(
                    metricValue,
                    100 * (lTimeB - lTimeA),
                    lWallTimeB - lWallTimeA);
#else
                FILETIME lCreationTime;
                FILETIME lExitTime;
                FILETIME lUserTimeA;
                FILETIME lKernelTimeA;
                FILETIME lUserTimeB;
                FILETIME lKernelTimeB;

                IntPtr thread     = GetCurrentThread();
                long   lWallTimeA = PerformanceObserverMono.NanoTime;

                GetThreadTimes(thread, out lCreationTime, out lExitTime, out lUserTimeA, out lKernelTimeA);
                observableCall.Invoke();
                GetThreadTimes(thread, out lCreationTime, out lExitTime, out lUserTimeB, out lKernelTimeB);

                long lWallTimeB = PerformanceObserverMono.NanoTime;

                // Calculate the time, not that the numbers represent 100-nanosecond intervals since
                // January 1, 601 (UTC).
                // https://msdn.microsoft.com/en-us/library/windows/desktop/ms724284(v=vs.85).aspx

                var kernelTimeA = (((long)lKernelTimeA.dwHighDateTime) << 32) | ((long)lKernelTimeA.dwLowDateTime);
                var kernelTimeB = (((long)lKernelTimeB.dwHighDateTime) << 32) | ((long)lKernelTimeB.dwLowDateTime);
                var userTimeA   = (((long)lUserTimeA.dwHighDateTime) << 32) | ((long)lUserTimeA.dwLowDateTime);
                var userTimeB   = (((long)lUserTimeB.dwHighDateTime) << 32) | ((long)lUserTimeB.dwLowDateTime);

                var execTimeNano = 100 * (userTimeB - userTimeA + kernelTimeB - kernelTimeA);

                perfCollector.Invoke(
                    statementMetricHandle,
                    execTimeNano,
                    lWallTimeB - lWallTimeA,
                    numInput);
#endif
            }
            else
            {
                observableCall.Invoke();
            }
        }