コード例 #1
0
        /// <summary>
        /// Creates a snapshot of the current state of the performance counter.
        /// </summary>
        /// <returns>Newly created snapshot.</returns>
        public CachePerformanceSnapshot Snapshot()
        {
            var snap = new CachePerformanceSnapshot(this.missCount, this.hitCount, this.missCountCache, this.hitCountCache, this.utxoSkipDisk)
            {
                Start = this.Start,
                // TODO: Would it not be better for these two guys to be part of the constructor? Either implicitly or explicitly.
                Taken = this.dateTimeProvider.GetUtcNow()
            };

            return(snap);
        }
コード例 #2
0
        private void AddBenchStats(StringBuilder log)
        {
            log.AppendLine("======CachedCoinView Bench======");
            DateTime now       = this.dateTimeProvider.GetUtcNow();
            var      lastFlush = (now - this.lastCacheFlushTime).TotalMinutes;

            log.AppendLine("Last flush ".PadRight(20) + Math.Round(lastFlush, 2) + " min ago (flush every " + TimeSpan.FromSeconds(this.CacheFlushTimeIntervalSeconds).TotalMinutes + " min)");

            log.AppendLine("Coin cache tip ".PadRight(20) + this.blockHash.Height);
            log.AppendLine("Coin store tip ".PadRight(20) + this.innerBlockHash.Height);
            log.AppendLine("block store tip ".PadRight(20) + "tbd");
            log.AppendLine();

            log.AppendLine("Cache entries ".PadRight(20) + this.cacheCount + " items");
            log.AppendLine("Dirty cache entries ".PadRight(20) + this.dirtyCacheCount + " items");

            log.AppendLine("Rewind data entries ".PadRight(20) + this.rewindDataCount + " items");
            var    cache            = this.cacheSizeBytes;
            var    rewind           = this.rewindDataSizeBytes;
            double filledPercentage = Math.Round(((cache + rewind) / (double)this.MaxCacheSizeBytes) * 100, 2);

            log.AppendLine("Cache size".PadRight(20) + cache.BytesToMegaBytes() + " MB");
            log.AppendLine("Rewind data size".PadRight(20) + rewind.BytesToMegaBytes() + " MB");
            log.AppendLine("Total cache size".PadRight(20) + (cache + rewind).BytesToMegaBytes() + " MB / " + this.consensusSettings.MaxCoindbCacheInMB + " MB (" + filledPercentage + "%)");

            CachePerformanceSnapshot snapShot = this.performanceCounter.Snapshot();

            if (this.latestPerformanceSnapShot == null)
            {
                log.AppendLine(snapShot.ToString());
            }
            else
            {
                log.AppendLine((snapShot - this.latestPerformanceSnapShot).ToString());
            }

            this.latestPerformanceSnapShot = snapShot;
        }