private BMCounterSource() : base(EventSourceSettings.EtwSelfDescribingEventFormat) { // Counter names should ideally be the same length, so I'm naming them with number-suffix. this.m_eventCounter = new EventCounter("BenchmarkCounter1", this) { // Same thing for these fields DisplayName = "ADisplayName", DisplayUnits = "MSec" }; this.m_pollingCounter = new PollingCounter("BenchmarkCounter2", this, () => 1) { DisplayName = "ADisplayName", DisplayUnits = "MSec" }; this.m_incrementingEventCounter = new IncrementingEventCounter("BenchmarkCounter3", this) { DisplayName = "ADisplayName", DisplayUnits = "MSec" }; this.m_incrementingPollingCounter = new IncrementingPollingCounter("BenchmarkCounter4", this, () => 1) { DisplayName = "ADisplayName", DisplayUnits = "MSec" }; }
protected override void OnEventCommand(EventCommandEventArgs command) { if (command.Command == EventCommand.Enable) { storageVirtualAllocBytes ??= new PollingCounter("storage-virtual-alloc-bytes", this, () => WindowsVirtualAllocManager.BytesCurrentlyAllocated); // storageNodesAllocated ??= new PollingCounter("storage-nodes-allocated", this, () => MCTSNodeStructStorage.NumAllocatedNodes); // storageNodeChildrenAllocated ??= new PollingCounter("storage-node-children-allocated", this, () => MCTSNodeStructChildStorage.NumAllocatedNodes); numBatchesGPU0 ??= new PollingCounter("gpu-0-batches", this, () => NNEvaluatorStats.TotalBatchesPerGPU[0]); numBatchesGPU1 ??= new PollingCounter("gpu-1-batches", this, () => NNEvaluatorStats.TotalBatchesPerGPU[1]); numBatchesGPU2 ??= new PollingCounter("gpu-2-batches", this, () => NNEvaluatorStats.TotalBatchesPerGPU[2]); numBatchesGPU3 ??= new PollingCounter("gpu-3-batches", this, () => NNEvaluatorStats.TotalBatchesPerGPU[3]); numPositionsGPU0 ??= new PollingCounter("gpu-0-positions", this, () => NNEvaluatorStats.TotalPosEvaluationsPerGPU[0]); numPositionsGPU1 ??= new PollingCounter("gpu-1-positions", this, () => NNEvaluatorStats.TotalPosEvaluationsPerGPU[1]); numPositionsGPU2 ??= new PollingCounter("gpu-2-positions", this, () => NNEvaluatorStats.TotalPosEvaluationsPerGPU[2]); numPositionsGPU3 ??= new PollingCounter("gpu-3-positions", this, () => NNEvaluatorStats.TotalPosEvaluationsPerGPU[3]); numNodesApplied ??= new IncrementingPollingCounter("applied", this, () => MCTSApply.TotalNumNodesApplied); numNodesDualSelectorDuplicate ??= new IncrementingPollingCounter("mcts-selected-dual-duplicate", this, () => MCTSNodesSelectedSet.TotalNumDualSelectorDuplicates); numNodesSelectedIntoTreeCache ??= new PollingCounter("mcts-nodes-selected-into-tree-cache", this, () => MCTSNodesSelectedSet.TotalNumNodesSelectedIntoTreeCache); numNodesAppliedFromTreeCache ??= new PollingCounter("mcts-nodes-appled-from-tree-cache", this, () => MCTSNodesSelectedSet.TotalNumNodesAppliedFromTreeCache); lastBatchYield ??= new PollingCounter("yield_pct_last_batch", this, () => 100.0f * MCTSIterator.LastBatchYieldFrac); batchYield ??= new PollingCounter("yield-pct-total", this, () => 100.0f * MCTSIterator.TotalYieldFrac); numAnnotations ??= new PollingCounter("num-annotations", this, () => MCTSTree.NumAnnotations); lastUnutilizedNNEvaluationTimeMS ??= new PollingCounter("nn-idle-time-ms-last", this, () => 1000.0f * MCTSSearchFlow.LastNNIdleTimeSecs); totalUnutilizedNNEvaluationTimeMS ??= new PollingCounter("nn-idle-time-sec-total", this, () => MCTSSearchFlow.TotalNNIdleTimeSecs); totalNNWaitingTimeMS ??= new PollingCounter("nn-wait-time-sec-total", this, () => MCTSSearchFlow.TotalNNWaitTimeSecs); makeNewRootTotalTimeSeconds ??= new PollingCounter("mcts-make-new-root-total-secs", this, () => MCTSManager.TotalTimeSecondsInMakeNewRoot);; totalNumMovesNoiseOverridden ??= new PollingCounter("noise_best_move_overrides_total", this, () => MCTSIterator.TotalNumMovesNoiseOverridden); nnCacheHitRate ??= new PollingCounter("mcts-nncache-hit-rate_pct", this, () => LeafEvaluatorCache.HitRatePct); opponentTreeReuseHitRate ??= new PollingCounter("mcts-opponent-tree-reuse-hit-rate-pct", this, () => 100.0f * LeafEvaluatorReuseOtherTree.HitRate); opponentTreeReuseNumHits ??= new PollingCounter("mcts-opponent-tree-reuse-hit-count", this, () => LeafEvaluatorReuseOtherTree.NumHits); nnTranspositionsHitRate ??= new PollingCounter("mcts-transposition-hit-rate_pct", this, () => LeafEvaluatorTransposition.HitRatePct); totalNumInFlightTranspositions ??= new PollingCounter("transpositions-in-flight-total", this, () => MCTSNodesSelectedSet.TotalNumInFlightTranspositions); numRootPreloadNodes ??= new IncrementingPollingCounter("mcts-root-preload-nodes", this, () => MCTSRootPreloader.TotalCumulativeRootPreloadNodes); mlhMoveModificationFraction ??= new PollingCounter("mcts-mlh-move-modified-pct", this, () => 100.0f * ManagerChooseRootMove.MLHMoveModifiedFraction); tablebaseHitsTotal ??= new PollingCounter("tablebase-hits-total", this, () => LC0DLLSyzygyEvaluator.NumTablebaseHits); tablebaseHits ??= new IncrementingPollingCounter("tablebase-hits", this, () => LC0DLLSyzygyEvaluator.NumTablebaseHits); tablebasePly1HitsTotal ??= new PollingCounter("tablebase-ply1-hits-total", this, () => LeafEvaluatorSyzygyPly1.NumHits); nodeAnnotateCacheHitRate = new PollingCounter("node-cache-hit-rate", this, () => MCTSTree.HitRate) { DisplayName = "node-annotation-cache-hit-rate" }; } }
public DotPulsarEventSource() : base("DotPulsar") { _totalClientsCounter = new PollingCounter("total-clients", this, () => _totalClients) { DisplayName = "Total number of clients" }; _currentClientsCounter = new PollingCounter("current-clients", this, () => _currentClients) { DisplayName = "Current number of clients" }; _totalConnectionsCounter = new PollingCounter("total-connections", this, () => _totalConnections) { DisplayName = "Total number of connections" }; _currentConnectionsCounter = new PollingCounter("current-connections", this, () => _currentConnections) { DisplayName = "Current number of connections" }; _totalConsumersCounter = new PollingCounter("total-consumers", this, () => _totalConsumers) { DisplayName = "Total number of consumers" }; _currentConsumersCounter = new PollingCounter("current-consumers", this, () => _currentConsumers) { DisplayName = "Current number of consumers" }; _totalProducersCounter = new PollingCounter("total-producers", this, () => _totalProducers) { DisplayName = "Total number of producers" }; _currentProducersCounter = new PollingCounter("current-producers", this, () => _currentProducers) { DisplayName = "Current number of producers" }; _totalReadersCounter = new PollingCounter("total-readers", this, () => _totalReaders) { DisplayName = "Total number of readers" }; _currentReadersCounter = new PollingCounter("current-readers", this, () => _currentReaders) { DisplayName = "Current number of readers" }; }
private FileOperationEventSource() : base(EventSourceSettings.EtwSelfDescribingEventFormat) { ActiveFolderOperationCounter = new IncrementingEventCounter("active-folder-operations", this) { DisplayName = "# of operations in the folder", DisplayUnits = "count" }; TotalFolderOperationCounter = new PollingCounter("total-folder-operations", this, () => Interlocked.Read(ref totalFolderOperationsCount)) { DisplayName = "# of operations in the folder (total)", }; }
private PerfCounters() { _messagesActive = new PollingCounter("messages-active", this, () => _messagesActiveCount); _messagesFailedTotal = new PollingCounter("messages-failed-total", this, () => _messagesErrorTotalCount); _messageTime = new EventCounter("message-time", this); _messagesAttemtped = new IncrementingEventCounter("messages-attempted", this); _sagaBlocks = new IncrementingEventCounter("saga-blocks", this); _messageRetries = new IncrementingEventCounter("messages-retry", this); _messagesFailed = new IncrementingEventCounter("messages-failed", this); _messagesComplete = new IncrementingEventCounter("messages-complete", this); _messagesSent = new IncrementingEventCounter("messages-sent", this); _messagesDelayed = new IncrementingEventCounter("messages-delayed", this); }
protected override void Dispose(bool disposing) { _requestCounter?.Dispose(); _requestCounter = null; _workingSetCounter?.Dispose(); _workingSetCounter = null; _totalRequestsCounter?.Dispose(); _totalRequestsCounter = null; _incrementingPollingCounter?.Dispose(); _incrementingPollingCounter = null; base.Dispose(disposing); }
protected override void OnEventCommand(EventCommandEventArgs command) { if (command.Command == EventCommand.Enable) { //请求响应耗时 _requestCounter = new EventCounter("request-time", this) { DisplayName = "Request Processing Time", DisplayUnits = "ms" }; //内存占用 _workingSetCounter = new PollingCounter("working-set", this, () => (double)(Environment.WorkingSet / 1_000_000)) { DisplayName = "Working Set", DisplayUnits = "MB" }; //总请求量 _totalRequestsCounter = new PollingCounter("total-requests", this, () => Volatile.Read(ref _totalRequests)) { DisplayName = "Total Requests", DisplayUnits = "次" }; //单位时间请求速率 _incrementingPollingCounter = new IncrementingPollingCounter("Request Rate", this, () => { return Volatile.Read(ref _totalRequests); }) { DisplayName = "Request Rate", DisplayUnits = "次/s", //时间间隔1s DisplayRateTimeScale = new TimeSpan(0, 0, 1) }; var monitorContentionCounter = new IncrementingPollingCounter("monitor-lock-contention-count", this, () => Monitor.LockContentionCount) { DisplayName = "Monitor Lock Contention Count", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; } }
protected override void EventCommandMethodCall(EventCommandEventArgs command) { if (command.Command != EventCommand.Enable) { return; } _activeHardConnections = _activeHardConnections ?? new PollingCounter("active-hard-connections", this, () => _activeHardConnectionsCounter) { DisplayName = "Actual active connections currently made to servers", DisplayUnits = "count" }; _hardConnectsPerSecond = _hardConnectsPerSecond ?? new IncrementingPollingCounter("hard-connects", this, () => _hardConnectsCounter) { DisplayName = "Actual connection rate to servers", DisplayUnits = "count / sec", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; _hardDisconnectsPerSecond = _hardDisconnectsPerSecond ?? new IncrementingPollingCounter("hard-disconnects", this, () => _hardDisconnectsCounter) { DisplayName = "Actual disconnection rate from servers", DisplayUnits = "count / sec", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; _activeSoftConnections = _activeSoftConnections ?? new PollingCounter("active-soft-connects", this, () => _activeSoftConnectionsCounter) { DisplayName = "Active connections retrieved from the connection pool", DisplayUnits = "count" }; _softConnects = _softConnects ?? new IncrementingPollingCounter("soft-connects", this, () => _softConnectsCounter) { DisplayName = "Rate of connections retrieved from the connection pool", DisplayUnits = "count / sec", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; _softDisconnects = _softDisconnects ?? new IncrementingPollingCounter("soft-disconnects", this, () => _softDisconnectsCounter) { DisplayName = "Rate of connections returned to the connection pool", DisplayUnits = "count / sec", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; _numberOfNonPooledConnections = _numberOfNonPooledConnections ?? new PollingCounter("number-of-non-pooled-connections", this, () => _nonPooledConnectionsCounter) { DisplayName = "Number of connections not using connection pooling", DisplayUnits = "count" }; _numberOfPooledConnections = _numberOfPooledConnections ?? new PollingCounter("number-of-pooled-connections", this, () => _pooledConnectionsCounter) { DisplayName = "Number of connections managed by the connection pool", DisplayUnits = "count" }; _numberOfActiveConnectionPoolGroups = _numberOfActiveConnectionPoolGroups ?? new PollingCounter("number-of-active-connection-pool-groups", this, () => _activeConnectionPoolGroupsCounter) { DisplayName = "Number of active unique connection strings", DisplayUnits = "count" }; _numberOfInactiveConnectionPoolGroups = _numberOfInactiveConnectionPoolGroups ?? new PollingCounter("number-of-inactive-connection-pool-groups", this, () => _inactiveConnectionPoolGroupsCounter) { DisplayName = "Number of unique connection strings waiting for pruning", DisplayUnits = "count" }; _numberOfActiveConnectionPools = _numberOfActiveConnectionPools ?? new PollingCounter("number-of-active-connection-pools", this, () => _activeConnectionPoolsCounter) { DisplayName = "Number of active connection pools", DisplayUnits = "count" }; _numberOfInactiveConnectionPools = _numberOfInactiveConnectionPools ?? new PollingCounter("number-of-inactive-connection-pools", this, () => _inactiveConnectionPoolsCounter) { DisplayName = "Number of inactive connection pools", DisplayUnits = "count" }; _numberOfActiveConnections = _numberOfActiveConnections ?? new PollingCounter("number-of-active-connections", this, () => _activeConnectionsCounter) { DisplayName = "Number of active connections", DisplayUnits = "count" }; _numberOfFreeConnections = _numberOfFreeConnections ?? new PollingCounter("number-of-free-connections", this, () => _freeConnectionsCounter) { DisplayName = "Number of ready connections in the connection pool", DisplayUnits = "count" }; _numberOfStasisConnections = _numberOfStasisConnections ?? new PollingCounter("number-of-stasis-connections", this, () => _stasisConnectionsCounter) { DisplayName = "Number of connections currently waiting to be ready", DisplayUnits = "count" }; _numberOfReclaimedConnections = _numberOfReclaimedConnections ?? new IncrementingPollingCounter("number-of-reclaimed-connections", this, () => _reclaimedConnectionsCounter) { DisplayName = "Number of reclaimed connections from GC", DisplayUnits = "count", DisplayRateTimeScale = TimeSpan.FromSeconds(1) }; }
public MeanAndVarianceCounter(string name, EventSource source) { _meanCounter = new PollingCounter($"{name} (mean)", source, Mean); _varianceCounter = new PollingCounter($"{name} (variance)", source, Variance); }
public SimpleEventSource(Func <double> getMockedCount, Func <double> getSuccessCount) { _failureCounter = new PollingCounter("failureCount", this, getSuccessCount); _successCounter = new PollingCounter("successCount", this, getMockedCount); }
public IncrementingCounter(string name, EventSource source) { _pollingCounter = new PollingCounter(name, source, Counter); }