public ConsensusStats(FullNode fullNode, CoinViewStack stack) { this.fullNode = fullNode; stack = new CoinViewStack(fullNode.CoinView); cache = stack.Find <CachedCoinView>(); dbreeze = stack.Find <DBreezeCoinView>(); bottom = stack.Bottom; lookaheadPuller = fullNode.ConsensusLoop.Puller as LookaheadBlockPuller; lastSnapshot = fullNode.ConsensusLoop.Validator.PerformanceCounter.Snapshot(); lastSnapshot2 = dbreeze?.PerformanceCounter.Snapshot(); lastSnapshot3 = cache?.PerformanceCounter.Snapshot(); }
public override string ToString() { StringBuilder builder = new StringBuilder(); if (this.TotalInsertedEntities > 0) { builder.AppendLine("Insert speed:".PadRight(LogsExtension.ColumnLength) + (this.TotalInsertTime.TotalMilliseconds / this.TotalInsertedEntities).ToString("0.0000") + " ms/utxo"); } builder.AppendLine("Insert time:".PadRight(LogsExtension.ColumnLength) + ConsensusPerformanceSnapshot.ToTimespan(this.TotalInsertTime)); builder.AppendLine("Inserted UTXO:".PadRight(LogsExtension.ColumnLength) + this.TotalInsertedEntities); if (this.TotalQueriedEntities > 0) { builder.AppendLine("Query speed:".PadRight(LogsExtension.ColumnLength) + (this.TotalQueryTime.TotalMilliseconds / this.TotalQueriedEntities).ToString("0.0000") + " ms/utxo"); } builder.AppendLine("Query time:".PadRight(LogsExtension.ColumnLength) + ConsensusPerformanceSnapshot.ToTimespan(this.TotalQueryTime)); builder.AppendLine("Queried UTXO:".PadRight(LogsExtension.ColumnLength) + this.TotalQueriedEntities); return(builder.ToString()); }
public void Log() { StringBuilder benchLogs = new StringBuilder(); if (lookaheadPuller != null) { benchLogs.AppendLine("======Block Puller======"); benchLogs.AppendLine("Lookahead:".PadRight(Logs.ColumnLength) + lookaheadPuller.ActualLookahead + " blocks"); benchLogs.AppendLine("Downloaded:".PadRight(Logs.ColumnLength) + lookaheadPuller.MedianDownloadCount + " blocks"); benchLogs.AppendLine("=========================="); } benchLogs.AppendLine("Persistent Tip:".PadRight(Logs.ColumnLength) + this.fullNode.Chain.GetBlock(bottom.GetBlockHashAsync().Result).Height); if (cache != null) { benchLogs.AppendLine("Cache Tip".PadRight(Logs.ColumnLength) + this.fullNode.Chain.GetBlock(cache.GetBlockHashAsync().Result).Height); benchLogs.AppendLine("Cache entries".PadRight(Logs.ColumnLength) + cache.CacheEntryCount); } var snapshot = this.fullNode.ConsensusLoop.Validator.PerformanceCounter.Snapshot(); benchLogs.AppendLine((snapshot - lastSnapshot).ToString()); lastSnapshot = snapshot; if (dbreeze != null) { var snapshot2 = dbreeze.PerformanceCounter.Snapshot(); benchLogs.AppendLine((snapshot2 - lastSnapshot2).ToString()); lastSnapshot2 = snapshot2; } if (cache != null) { var snapshot3 = cache.PerformanceCounter.Snapshot(); benchLogs.AppendLine((snapshot3 - lastSnapshot3).ToString()); lastSnapshot3 = snapshot3; } benchLogs.AppendLine(this.fullNode.ConnectionManager.GetStats()); Logs.Bench.LogInformation(benchLogs.ToString()); }