Exemplo n.º 1
0
 public CachePerformanceSnapshot Snapshot()
 {
     var snap = new CachePerformanceSnapshot(this.missCount, this.hitCount)
     {
         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;
 }
        public CachePerformanceSnapshot Snapshot()
        {
#if !(PORTABLE || NETCORE)
            Thread.MemoryBarrier();
#endif
            var snap = new CachePerformanceSnapshot(this._MissCount, this._HitCount)
            {
                Start = this.Start,
                Taken = DateTime.UtcNow
            };
            return(snap);
        }
        private void AddBenchStats(StringBuilder log)
        {
            log.AppendLine("======CashedCoinView Bench======");

            log.AppendLine("Cache entries".PadRight(20) + this.cacheEntryCount);

            CachePerformanceSnapshot snapShot = this.performanceCounter.Snapshot();

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

            this.latestPerformanceSnapShot = snapShot;
        }
        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;
        }