Example #1
0
 protected SecureControllerBase(IAuthenticationProvider authenticationProvider,
                                ILogger exceptionLogger,
                                IPerformanceCounter performanceCounter)
     : base(exceptionLogger, performanceCounter)
 {
     _authenticationProvider = authenticationProvider;
 }
        private void SetCounterProperties(string instanceName)
        {
            bool loadCounters = true;

            foreach (var property in _counterProperties)
            {
                PerformanceCounterAttribute attribute = GetPerformanceCounterAttribute(property);

                if (attribute == null)
                {
                    continue;
                }

                IPerformanceCounter counter = null;

                if (loadCounters)
                {
                    counter = LoadCounter(CategoryName, attribute.Name, instanceName);

                    if (counter == null)
                    {
                        loadCounters = false;
                    }
                }

                counter = counter ?? _noOpCounter;

                // Initialize the counter sample
                counter.NextSample();

                property.SetValue(this, counter, null);
            }
        }
Example #3
0
        public List <Range> GetRangesFirst(QuadTree tree)
        {
            List <Range> results = new List <Range>();

            for (var col = 0; col < tree.Bounds.ColumnsCount; col++)
            {
                for (var row = 0; row < tree.Bounds.RowsCount; row++)
                {
                    Range?range = null;
                    IPerformanceCounter counter = null;
                    using (counter = new PerformanceCounter())
                    {
                        range = tree.QueryFirst(new Position(row, col));
                    }
                    TotalQueries++;
                    TotalTimeSpent += counter.GetMilisec();
                    if (range != null)
                    {
                        results.Add(range.Value);
                    }
                }
            }
            AverageTimeSpent = TotalTimeSpent / TotalQueries;
            return(results);
        }
Example #4
0
        public List <Range> GetRanges(RangeCreator ranges)
        {
            List <Range> results = new List <Range>();

            for (var col = 0; col < ranges.ColCount; col++)
            {
                for (var row = 0; row < ranges.RowCount; row++)
                {
                    Range?index;
                    IPerformanceCounter counter = null;
                    using (counter = new PerformanceCounter())
                    {
                        index = ranges.SpannedRangesList.GetFirstIntersectedRange(new Position(row, col));
                    }
                    TotalQueries++;
                    TotalTimeSpent += counter.GetMilisec();
                    if (index != null)
                    {
                        results.Add(index.Value);
                    }
                }
            }
            AverageTimeSpent = TotalTimeSpent / TotalQueries;
            return(results);
        }
Example #5
0
        private void SetCounterProperties()
        {
            var loadCounters = true;

            foreach (var property in _counterProperties)
            {
                PerformanceCounterAttribute attribute = GetPerformanceCounterAttribute(property);

                if (attribute == null)
                {
                    continue;
                }

                IPerformanceCounter counter = null;

                if (loadCounters)
                {
                    counter = LoadCounter(CategoryName, attribute.Name, isReadOnly: false);

                    if (counter == null)
                    {
                        // We failed to load the counter so skip the rest
                        loadCounters = false;
                    }
                }

                counter = counter ?? _noOpCounter;

                property.SetValue(this, counter, null);
            }
        }
        private void SetCounterProperties(string instanceName)
        {
            var canLoadCounters = true;

            foreach (var property in CounterProperties)
            {
                PerformanceCounterAttribute attribute = GetPerformanceCounterAttribute(property);
                if (attribute == null)
                {
                    continue;
                }

                IPerformanceCounter counter = null;
                if (canLoadCounters)
                {
                    counter = LoadCounter(CategoryName, attribute.Name, instanceName, isReadOnly: false);

                    if (counter == null)
                    {
                        // We failed to load the counter so skip the rest
                        canLoadCounters = false;
                    }
                }

                counter = counter ?? NoOpCounter;

                // Initialize the counter sample
                counter.NextValue();

                property.SetValue(this, counter, null);
            }
        }
        public MembershipInstrumentationProvider(bool enabled)
        {
            var factory = new PerformanceCounterFactory(InstrumentationNames.DemoMembershipCategory, InstrumentationNames.InstanceSuffix, enabled);

            authenticationCounter       = factory.Create("Authentication Requests/sec", "Total Authentication Requests");
            authenticationFailedCounter = factory.Create("Authentication Failed Requests/sec", "Total Authentication Failed Requests");
        }
Example #8
0
        public ResourceLoadProvider(ConcurrentDictionary <Guid, List <IResource> > workspaceResources, IServerVersionRepository serverVersionRepository, IEnumerable <DynamicService> managementServices = null)
            : this(new FileWrapper())
        {
            try
            {
                _perfCounter = CustomContainer.Get <IWarewolfPerformanceCounterLocater>().GetCounter("Count of requests for workflows which don't exist");
            }
            catch (Exception e)
            {
                Dev2Logger.Warn("Error getting perf counters. " + e.Message, "Warewolf Warn");
            }
            if (managementServices != null)
            {
                foreach (var service in managementServices)
                {
                    var resource = new ManagementServiceResource(service);
                    ManagementServices.TryAdd(resource.ResourceID, resource);
                }
            }
            _workspaceResources      = workspaceResources;
            _serverVersionRepository = serverVersionRepository;
            LoadFrequentlyUsedServices();

            _typeCache = new TypeCache();
            LoadResourceTypeCache();
        }
Example #9
0
        public ILogConfiguration Custom(IPerformanceCounter performanceCounter)
        {
            if (performanceCounter != null)
            {
                _perfCounters.Add(performanceCounter);
            }

            return(this);
        }
Example #10
0
 public CounterListener(string category, string instance, string counterName,
                        PerformanceCounterFactory counterFactory)
 {
     _category       = category;
     _instance       = instance;
     _counterName    = counterName;
     _counterFactory = counterFactory;
     _counter        = CreateCounter(category, instance, counterName);
 }
Example #11
0
 public ExecutionDebugInfo(DaisyAst ast, DaisyMode mode)
 {
     _mode = mode;
     Ast = ast;
     _performanceCounter = mode == DaisyMode.Debug
         ? new PerformanceCounter()
         : NoopPerformanceCounter.Instance;
     measurements = new Lazy<PerformanceMeasurments>(() => PerformanceCounter.Measurments);
 }
Example #12
0
 public ExecutionDebugInfo(DaisyAst ast, DaisyMode mode)
 {
     _mode = mode;
     Ast   = ast;
     _performanceCounter = mode == DaisyMode.Debug
         ? new PerformanceCounter()
         : NoopPerformanceCounter.Instance;
     measurements = new Lazy <PerformanceMeasurments>(() => PerformanceCounter.Measurments);
 }
Example #13
0
        public CachingInstrumentationProvider(string category, string instanceNameSuffix, bool enabled)
        {
            var factory = new PerformanceCounterFactory(category, instanceNameSuffix, enabled);

            m_failedCounter  = factory.Create("Total Cache Failed Requests", "Cache Failed Requests/sec");
            m_hitsCounter    = factory.Create("Total Cache Hits", "Cache Hits/sec");
            m_missesCounter  = factory.Create("Total Cache Misses", "Cache Misses/sec");
            m_storedCounter  = factory.Create("Total Cache Store Requests", "Cache Store Requests/sec");
            m_removedCounter = factory.Create("Total Cache Remove Requests", "Cache Remove Requests/sec");
        }
        public LifecycledComponentsReleasePolicy(ITrackedComponentsDiagnostic trackedComponentsDiagnostic, IPerformanceCounter countOfTrackedInstances)
        {
            this.trackedComponentsDiagnostic = trackedComponentsDiagnostic;
            this.countOfTrackedInstances     = countOfTrackedInstances;

            if (trackedComponentsDiagnostic != null)
            {
                trackedComponentsDiagnostic.TrackedInstancesRequested += trackedComponentsDiagnostic_TrackedInstancesRequested;
            }
        }
		public LifecycledComponentsReleasePolicy(ITrackedComponentsDiagnostic trackedComponentsDiagnostic, IPerformanceCounter countOfTrackedInstances)
		{
			this.trackedComponentsDiagnostic = trackedComponentsDiagnostic;
			this.countOfTrackedInstances = countOfTrackedInstances;

			if (trackedComponentsDiagnostic != null)
			{
				trackedComponentsDiagnostic.TrackedInstancesRequested += trackedComponentsDiagnostic_TrackedInstancesRequested;
			}
		}
Example #16
0
        public CaptchaInstrumentationProvider(string category, string instanceNameSuffix, bool enabled)
        {
            var factory = new PerformanceCounterFactory(category, instanceNameSuffix, enabled);

            m_issuedCounter             = factory.Create("Total Captcha Requests", "Captcha Requests/sec");
            m_failedCounter             = factory.Create("Total Captcha Failed Requests", "Captcha Failed Requests/sec");
            m_renderedCounter           = factory.Create("Total Captcha Render Requests", "Captcha Render Requests/sec");
            m_verificationCounter       = factory.Create("Total Captcha Verification Requests", "Captcha Verification Requests/sec");
            m_verificationFailedCounter = factory.Create("Total Captcha Verification Failed Requests", "Captcha Verification Failed Requests/sec");
        }
Example #17
0
 private static void CtorTransient(long series, IPerformanceCounter performanceCounter)
 {
     using (performanceCounter.Run())
     {
         for (var i = 0; i < series; i++)
         {
             CreateTransientService().DoSomething();
         }
     }
 }
        private LogicalDiskMeter(char?driveLetter, IPerformanceCounterFactory counterFactory)
        {
            var instanceName = driveLetter.HasValue ? driveLetter.ToString() + Path.VolumeSeparatorChar : "_Total";

            driveName = driveLetter.HasValue ? instanceName : "Total";

            counter = LogicalDiskMeterHelper
                      .CreateCounters(counterFactory)
                      .Build(instanceName);
        }
Example #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CodeClock"/> class.
 /// </summary>
 public CodeClock()
 {
     if (Platform.IsWin32Platform)
     {
         _clock = new Win32PerformanceCounter();
     }
     else
     {
         _clock = new DefaultPerformanceCounter();
     }
 }
Example #20
0
 private HostNetworkUsageMeter(IPerformanceCounterFactory counterFactory)
 {
     counter = counterFactory.Create <InterfaceUsageMetrics>()
               .AddCounter("Network Interface", "Bytes Received/sec",
                           (c, v) => c.Result.ReceivedBytesPerSecond = (long)v)
               .AddCounter("Network Interface", "Bytes Sent/sec",
                           (c, v) => c.Result.SentBytesPerSecond = (long)v)
               .AddCounter("Network Interface", "Current Bandwidth",
                           (c, v) => c.Result.BandwidthBytes = (long)(v / 8))
               .BuildForMultipleInstances("*");
 }
Example #21
0
        public GCTracker([NotNull] IPerformanceCounter gcCounter, [NotNull] List <IPerformanceCounter> gcCounters, [NotNull] IApplicationLifetimeManager applicationLifetimeManager)
        {
            _GcCounter  = gcCounter ?? throw new ArgumentNullException(nameof(gcCounter));
            _GcCounters = gcCounters ?? throw new ArgumentNullException(nameof(gcCounters));
            _ApplicationLifetimeManager = applicationLifetimeManager ?? throw new ArgumentNullException(nameof(applicationLifetimeManager));

            for (int index = 0; index < _GcCounters.Count; index++)
            {
                _PreviousValues.Add(GC.CollectionCount(index));
            }
        }
 public PerfmonExecutionContainer(IEsbExecutionContainer container)
 {
     VerifyArgument.IsNotNull(nameof(Container), container);
     _container           = container;
     _locater             = CustomContainer.Get <IWarewolfPerformanceCounterLocater>();
     _recPerSecondCounter = _locater.GetCounter("Request Per Second");
     _currentConnections  = _locater.GetCounter("Concurrent requests currently executing");
     _avgTime             = _locater.GetCounter("Average workflow execution time");
     _totalErrors         = _locater.GetCounter("Total Errors");
     _stopwatch           = new Stopwatch();
     _stopwatch.Start();
 }
        public ConsumerPerformanceCounter(ICounterFactory factory, string consumerType)
        {
            if (consumerType.Length > 127)
                consumerType = consumerType.Substring(consumerType.Length - 127);

            _totalMessages = factory.Create(BuiltInCounters.Consumers.Category, ConsumerPerformanceCounters.TotalMessages.CounterName, consumerType);
            _consumeRate = factory.Create(BuiltInCounters.Consumers.Category, ConsumerPerformanceCounters.ConsumeRate.CounterName, consumerType);
            _duration = factory.Create(BuiltInCounters.Consumers.Category, ConsumerPerformanceCounters.Duration.CounterName, consumerType);
            _durationBase = factory.Create(BuiltInCounters.Consumers.Category, ConsumerPerformanceCounters.DurationBase.CounterName, consumerType);
            _totalFaults = factory.Create(BuiltInCounters.Consumers.Category, ConsumerPerformanceCounters.TotalFaults.CounterName, consumerType);
            _faultPercentage = factory.Create(BuiltInCounters.Consumers.Category, ConsumerPerformanceCounters.FaultPercentage.CounterName, consumerType);
            _faultPercentageBase = factory.Create(BuiltInCounters.Consumers.Category, ConsumerPerformanceCounters.FaultPercentageBase.CounterName, consumerType);
        }
Example #24
0
        public void WarewolfAverageExecutionTimePerformanceCounterByResource_Construct()
        {
            var mockPerformanceCounterFactory = new Mock <IRealPerformanceCounterFactory>();
            var performanceCounterFactory     = mockPerformanceCounterFactory.Object;
            var originalCounter         = new WarewolfAverageExecutionTimePerformanceCounterByResource(_resourceGuid, _categoryInstanceName, performanceCounterFactory);
            IPerformanceCounter counter = originalCounter;

            Assert.IsTrue(counter.IsActive);
            Assert.AreEqual(WarewolfPerfCounterType.AverageExecutionTime, counter.PerfCounterType);
            Assert.AreEqual(GlobalConstants.WarewolfServices, counter.Category);
            Assert.AreEqual(CounterName, counter.Name);
            Assert.AreEqual(_resourceGuid, originalCounter.ResourceId);
        }
Example #25
0
 protected ServerAuthorizationService(ISecurityService securityService)
     : base(securityService, true)
 {
     _timeOutPeriod = securityService.TimeOutPeriod;
     try
     {
         _perfCounter = CustomContainer.Get <IWarewolfPerformanceCounterLocater>().GetCounter("Count of Not Authorised errors");
     }
     catch (Exception e)
     {
         Dev2Logger.Error(e, GlobalConstants.WarewolfError);
     }
 }
        public void Finalize(IContainer container)
        {
            List <IPerformanceCounter> gcCounters = new List <IPerformanceCounter>();

            for (int index = 0; index <= GC.MaxGeneration; index++)
            {
                gcCounters.Add(_PerformanceCounters.GetByKey($"System.Memory.GC.{index}"));
            }

            IPerformanceCounter gcCounter = _PerformanceCounters.GetByKey("System.Memory.GC");

            // ReSharper disable once ObjectCreationAsStatement
            new GCTracker(gcCounter, gcCounters, _ApplicationLifetimeManager);
        }
Example #27
0
        private void UpdateTotalRowCount(IPerformanceCounter counter)
        {
            if (counter == null)
            {
                this.toolStripStatusLabelRowCount.Text = string.Format(
                    "Row count: {0}",
                    m_custTable.Rows.Count);
                return;
            }

            this.toolStripStatusLabelRowCount.Text = string.Format(
                "Row count: {0}. added in {1} ms",
                m_custTable.Rows.Count,
                counter.GetMilisec());
        }
Example #28
0
        public ConsumerPerformanceCounter(ICounterFactory factory, string consumerType)
        {
            if (consumerType.Length > 127)
            {
                consumerType = consumerType.Substring(consumerType.Length - 127);
            }

            _totalMessages       = factory.Create(BuiltInCounters.Consumers.Category, ConsumerPerformanceCounters.TotalMessages.CounterName, consumerType);
            _consumeRate         = factory.Create(BuiltInCounters.Consumers.Category, ConsumerPerformanceCounters.ConsumeRate.CounterName, consumerType);
            _duration            = factory.Create(BuiltInCounters.Consumers.Category, ConsumerPerformanceCounters.Duration.CounterName, consumerType);
            _durationBase        = factory.Create(BuiltInCounters.Consumers.Category, ConsumerPerformanceCounters.DurationBase.CounterName, consumerType);
            _totalFaults         = factory.Create(BuiltInCounters.Consumers.Category, ConsumerPerformanceCounters.TotalFaults.CounterName, consumerType);
            _faultPercentage     = factory.Create(BuiltInCounters.Consumers.Category, ConsumerPerformanceCounters.FaultPercentage.CounterName, consumerType);
            _faultPercentageBase = factory.Create(BuiltInCounters.Consumers.Category, ConsumerPerformanceCounters.FaultPercentageBase.CounterName, consumerType);
        }
Example #29
0
        public void WarewolfAverageExecutionTimePerformanceCounter_Construct()
        {
            var mockPerformanceCounterFactory = new Mock <IRealPerformanceCounterFactory>();
            var performanceCounterFactory     = mockPerformanceCounterFactory.Object;

            using (var originalCounter = new WarewolfAverageExecutionTimePerformanceCounter(performanceCounterFactory))
            {
                IPerformanceCounter counter = originalCounter;

                Assert.IsTrue(counter.IsActive);
                Assert.AreEqual(WarewolfPerfCounterType.AverageExecutionTime, counter.PerfCounterType);
                Assert.AreEqual(GlobalConstants.Warewolf, counter.Category);
                Assert.AreEqual(CounterName, counter.Name);
            }
        }
Example #30
0
        private static void CtorSingleton(long series, IPerformanceCounter performanceCounter)
        {
            lock (LockObject)
            {
                _service2 = null;
            }

            using (performanceCounter.Run())
            {
                for (var i = 0; i < series; i++)
                {
                    CreateSingletonService().DoSomething();
                }
            }
        }
Example #31
0
 private static void CastleWindsorTransient(long series, IPerformanceCounter performanceCounter)
 {
     using (var container = new WindsorContainer())
     {
         container.Register(Component.For <IService1>().ImplementedBy <Service1>().LifestyleTransient());
         container.Register(Component.For <IService2>().ImplementedBy <Service2>().LifestyleTransient());
         container.Register(Component.For <IService3>().ImplementedBy <Service3>().LifestyleTransient());
         container.Register(Component.For <IService4>().ImplementedBy <Service4>().LifestyleTransient());
         using (performanceCounter.Run())
         {
             for (var i = 0; i < series; i++)
             {
                 container.Resolve <IService1>().DoSomething();
             }
         }
     }
 }
Example #32
0
 private static void LightInjectSingleton(long series, IPerformanceCounter performanceCounter)
 {
     using (var container = new ServiceContainer())
     {
         container.Register <IService1, Service1>();
         container.Register <IService2, Service2>(new PerContainerLifetime());
         container.Register <IService3, Service3>();
         container.Register <IService4, Service4>();
         using (performanceCounter.Run())
         {
             for (var i = 0; i < series; i++)
             {
                 container.GetInstance <IService1>().DoSomething();
             }
         }
     }
 }
Example #33
0
 private static void DryIocTransient(long series, IPerformanceCounter performanceCounter)
 {
     using (var container = new Container())
     {
         container.Register <IService1, Service1>();
         container.Register <IService2, Service2>();
         container.Register <IService3, Service3>();
         container.Register <IService4, Service4>();
         using (performanceCounter.Run())
         {
             for (var i = 0; i < series; i++)
             {
                 container.Resolve <IService1>().DoSomething();
             }
         }
     }
 }
        public ConsumerPerformanceCounter(string consumerType)
        {
            if (consumerType.Length > 127)
                consumerType = consumerType.Substring(consumerType.Length - 127);

            _totalMessages = ConsumerPerformanceCounters.CreateCounter(
                ConsumerPerformanceCounters.TotalMessages.CounterName, consumerType);
            _consumeRate = ConsumerPerformanceCounters.CreateCounter(
                ConsumerPerformanceCounters.ConsumeRate.CounterName, consumerType);
            _duration = ConsumerPerformanceCounters.CreateCounter(
                ConsumerPerformanceCounters.Duration.CounterName, consumerType);
            _durationBase = ConsumerPerformanceCounters.CreateCounter(
                ConsumerPerformanceCounters.DurationBase.CounterName, consumerType);
            _totalFaults = ConsumerPerformanceCounters.CreateCounter(
                ConsumerPerformanceCounters.TotalFaults.CounterName, consumerType);
            _faultPercentage = ConsumerPerformanceCounters.CreateCounter(
                ConsumerPerformanceCounters.FaultPercentage.CounterName, consumerType);
            _faultPercentageBase = ConsumerPerformanceCounters.CreateCounter(
                ConsumerPerformanceCounters.FaultPercentageBase.CounterName, consumerType);
        }
		public LifecycledComponentsReleasePolicy(IPerformanceCounter countOfTrackedInstances)
		{
			this.countOfTrackedInstances = countOfTrackedInstances;
		}
 private CounterTimer(IPerformanceCounter counter)
 {
     Counter = counter;
 }
 private CounterDelta32(IPerformanceCounter counter)
 {
     Counter = counter;
 }
 private NumberOfItems32(IPerformanceCounter counter)
 {
     Counter = counter;
 }
 private Timer100NsInverse(IPerformanceCounter counter)
 {
     Counter = counter;
 }
 private RateOfCountsPerSecond32(IPerformanceCounter counter)
 {
     Counter = counter;
 }
Example #41
0
		private void UpdateTotalRowCount(IPerformanceCounter counter)
		{
			if (counter == null)
			{
				this.toolStripStatusLabelRowCount.Text = string.Format(
					"Row count: {0}",
					m_custTable.Rows.Count);
				return;
			}
			
			this.toolStripStatusLabelRowCount.Text = string.Format(
				"Row count: {0}. added in {1} ms",
				m_custTable.Rows.Count,
				counter.GetMilisec());
		}
 /// <summary>
 /// Constructs the timer from the two performance counters.
 /// </summary>
 /// <param name="counter">The primary counter.</param>
 /// <param name="counterBase">The base counter.</param>
 private AverageTimer(IPerformanceCounter counter, IPerformanceCounter counterBase)
 {
     Counter = counter;
     CounterBase = counterBase;
 }
Example #43
0
		/// <summary>
        /// Initializes a new instance of the <see cref="CodeClock"/> class.
		/// </summary>
		public CodeClock()
		{
			if(Platform.IsWin32Platform)
			{
				_clock = new Win32PerformanceCounter();
			}
			else
			{
				_clock = new DefaultPerformanceCounter();
			}
		}
 public void Close()
 {
     if (ConsumerThreadCount != null)
     {
         ConsumerThreadCount.Dispose();
         ConsumerThreadCount = null;
     }
     if (ReceiveThreadCount != null)
     {
         ReceiveThreadCount.Dispose();
         ReceiveThreadCount = null;
     }
     if (ReceiveRate != null)
     {
         ReceiveRate.Dispose();
         ReceiveRate = null;
     }
     if (PublishRate != null)
     {
         PublishRate.Dispose();
         PublishRate = null;
     }
     if (SendRate != null)
     {
         SendRate.Dispose();
         SendRate = null;
     }
     if (ReceiveCount != null)
     {
         ReceiveCount.Dispose();
         ReceiveCount = null;
     }
     if (PublishCount != null)
     {
         PublishCount.Dispose();
         PublishCount = null;
     }
     if (SentCount != null)
     {
         SentCount.Dispose();
         SentCount = null;
     }
     if (ConsumerDuration != null)
     {
         ConsumerDuration.Dispose();
         ConsumerDuration = null;
     }
     if (ConsumerDurationBase != null)
     {
         ConsumerDurationBase.Dispose();
         ConsumerDurationBase = null;
     }
     if (ReceiveDuration != null)
     {
         ReceiveDuration.Dispose();
         ReceiveDuration = null;
     }
     if (ReceiveDurationBase != null)
     {
         ReceiveDurationBase.Dispose();
         ReceiveDurationBase = null;
     }
     if (PublishDuration != null)
     {
         PublishDuration.Dispose();
         PublishDuration = null;
     }
     if (PublishDurationBase != null)
     {
         PublishDurationBase.Dispose();
         PublishDurationBase = null;
     }
 }
 /// <summary>
 /// Constructs the timer from the two performance counters.
 /// </summary>
 /// <param name="counter">The primary counter.</param>
 /// <param name="counterBase">The base counter.</param>
 private SampleFraction(IPerformanceCounter counter, IPerformanceCounter counterBase)
 {
     Counter = counter;
     CounterBase = counterBase;
 }
		private LifecycledComponentsReleasePolicy(LifecycledComponentsReleasePolicy parent)
		{
			this.parent = parent;
			countOfTrackedInstances = parent.countOfTrackedInstances;
		}