Example #1
0
        public ConsensusPerformanceSnapshot Snapshot()
        {
            var snap = new ConsensusPerformanceSnapshot(this.ProcessedInputs, this.ProcessedTransactions, this.ProcessedBlocks, this.blockFetchingTime, this.blockProcessingTime, this.uTXOFetchingTime)
            {
                Start = this.Start,
                Taken = this.dateTimeProvider.GetUtcNow()
            };

            return(snap);
        }
Example #2
0
        public ConsensusPerformanceSnapshot Snapshot()
        {
#if !(PORTABLE || NETCORE)
            Thread.MemoryBarrier();
#endif
            var snap = new ConsensusPerformanceSnapshot(this.ProcessedInputs, this.ProcessedTransactions, this.ProcessedBlocks, this._BlockFetchingTime, this._BlockProcessingTime, this._UTXOFetchingTime)
            {
                Start = this.Start,
                Taken = DateTime.UtcNow
            };
            return(snap);
        }
        public ConsensusStats(CoinViewStack stack, CoinView coinView, ConsensusLoop consensusLoop, ChainBehavior.ChainState chainState, ConcurrentChain chain, IConnectionManager connectionManager)
        {
            stack        = new CoinViewStack(coinView);
            this.cache   = stack.Find <CachedCoinView>();
            this.dbreeze = stack.Find <DBreezeCoinView>();
            this.bottom  = stack.Bottom;

            this.consensusLoop   = consensusLoop;
            this.lookaheadPuller = this.consensusLoop.Puller as LookaheadBlockPuller;

            this.lastSnapshot      = consensusLoop.Validator.PerformanceCounter.Snapshot();
            this.lastSnapshot2     = this.dbreeze?.PerformanceCounter.Snapshot();
            this.lastSnapshot3     = this.cache?.PerformanceCounter.Snapshot();
            this.chainState        = chainState;
            this.chain             = chain;
            this.connectionManager = connectionManager;
        }
Example #4
0
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            if (TotalInsertedEntities > 0)
            {
                builder.AppendLine("Insert speed:".PadRight(Logs.ColumnLength) + (TotalInsertTime.TotalMilliseconds / TotalInsertedEntities).ToString("0.0000") + " ms/utxo");
            }
            builder.AppendLine("Insert time:".PadRight(Logs.ColumnLength) + ConsensusPerformanceSnapshot.ToTimespan(TotalInsertTime));
            builder.AppendLine("Inserted UTXO:".PadRight(Logs.ColumnLength) + TotalInsertedEntities);
            if (TotalQueriedEntities > 0)
            {
                builder.AppendLine("Query speed:".PadRight(Logs.ColumnLength) + (TotalQueryTime.TotalMilliseconds / TotalQueriedEntities).ToString("0.0000") + " ms/utxo");
            }
            builder.AppendLine("Query time:".PadRight(Logs.ColumnLength) + ConsensusPerformanceSnapshot.ToTimespan(TotalQueryTime));
            builder.AppendLine("Queried UTXO:".PadRight(Logs.ColumnLength) + TotalQueriedEntities);
            return(builder.ToString());
        }
        public void Log()
        {
            StringBuilder benchLogs = new StringBuilder();

            if (this.lookaheadPuller != null)
            {
                benchLogs.AppendLine("======Block Puller======");
                benchLogs.AppendLine("Lookahead:".PadRight(Logs.ColumnLength) + this.lookaheadPuller.ActualLookahead + " blocks");
                benchLogs.AppendLine("Downloaded:".PadRight(Logs.ColumnLength) + this.lookaheadPuller.MedianDownloadCount + " blocks");
                benchLogs.AppendLine("==========================");
            }
            benchLogs.AppendLine("Persistent Tip:".PadRight(Logs.ColumnLength) + this.chain.GetBlock(this.bottom.GetBlockHashAsync().Result).Height);
            if (this.cache != null)
            {
                benchLogs.AppendLine("Cache Tip".PadRight(Logs.ColumnLength) + this.chain.GetBlock(this.cache.GetBlockHashAsync().Result).Height);
                benchLogs.AppendLine("Cache entries".PadRight(Logs.ColumnLength) + this.cache.CacheEntryCount);
            }

            var snapshot = this.consensusLoop.Validator.PerformanceCounter.Snapshot();

            benchLogs.AppendLine((snapshot - this.lastSnapshot).ToString());
            this.lastSnapshot = snapshot;

            if (this.dbreeze != null)
            {
                var snapshot2 = this.dbreeze.PerformanceCounter.Snapshot();
                benchLogs.AppendLine((snapshot2 - this.lastSnapshot2).ToString());
                this.lastSnapshot2 = snapshot2;
            }
            if (this.cache != null)
            {
                var snapshot3 = this.cache.PerformanceCounter.Snapshot();
                benchLogs.AppendLine((snapshot3 - this.lastSnapshot3).ToString());
                this.lastSnapshot3 = snapshot3;
            }
            benchLogs.AppendLine(this.connectionManager.GetStats());
            Logs.Bench.LogInformation(benchLogs.ToString());
        }