Example #1
0
        public void Run()
        {
            var resources = GpuResourceManager.Instance.GetResources().ToArray();

            ResourceCounter.SetValue(resources.Length);

            Memory.SetValue(GpuResourceManager.GetMemoryUsage);
        }
        // ReSharper disable UnusedMember.Global
        public async Task Invoke(HttpContext context)
        // ReSharper restore UnusedMember.Global
        {
            _logger.MiddlewareExecuting <ResourceMiddleware>();

            _maxWorkingSet.SetValue(_ResourceMetrics.MaxWorkingSet);
            _pagedMemorySize64.SetValue(_ResourceMetrics.PagedMemorySize64);
            _nonpagedSystemMemorySize64.SetValue(_ResourceMetrics.NonpagedSystemMemorySize64);
            _peakPagedMemorySize64.SetValue(_ResourceMetrics.PeakPagedMemorySize64);
            _peakWorkingSet64.SetValue(_ResourceMetrics.PeakWorkingSet64);
            _totalProcessorTime.SetValue(_ResourceMetrics.TotalProcessorTime);
            _userProcessorTime.SetValue(_ResourceMetrics.UserProcessorTime);
            _virtualMemorySize64.SetValue(_ResourceMetrics.VirtualMemorySize64);
            _workingSet64.SetValue(_ResourceMetrics.WorkingSet64);
            _threadsCount.SetValue(_ResourceMetrics.ThreadsCount);
            _gcCollectionCount.SetValue(_ResourceMetrics.GCCollectionCount);
            _gcTotalMemory.SetValue(_ResourceMetrics.GCTotalMemory);
            _lastGCTime.SetValue(_ResourceMetrics.LastGCTime);

            await _next(context);

            _logger.MiddlewareExecuted <ResourceMiddleware>();
        }