Example #1
0
 public BlockStoreStats(IBlockRepository blockRepository, IBlockStoreCache blockStoreCache, ILogger logger)
 {
     this.repository             = blockRepository;
     this.cache                  = blockStoreCache as BlockStoreCache;
     this.logger                 = logger;
     this.lastRepositorySnapshot = this.repository?.PerformanceCounter.Snapshot();
     this.lastCacheSnapshot      = this.cache?.PerformanceCounter.Snapshot();
 }
Example #2
0
        public virtual BlockStoreCachePerformanceSnapshot Snapshot()
        {
            var snap = new BlockStoreCachePerformanceSnapshot(this.CacheHitCount, this.CacheMissCount, this.CacheRemoveCount, this.CacheSetCount, this.Name)
            {
                Start = this.Start,
                Taken = this.dateTimeProvider.GetUtcNow()
            };

            return(snap);
        }
        public BlockStoreCachePerformanceSnapshot Snapshot()
        {
#if !(PORTABLE || NETCORE)
            Thread.MemoryBarrier();
#endif
            var snap = new BlockStoreCachePerformanceSnapshot(this.CacheHitCount, this.CacheMissCount, this.CacheRemoveCount, this.CacheSetCount)
            {
                Start = this.Start,
                Taken = DateTime.UtcNow
            };
            return(snap);
        }
Example #4
0
        public void Log()
        {
            StringBuilder performanceLogBuilder = new StringBuilder();

            if (this.repository != null)
            {
                var snapshot = this.repository.PerformanceCounter.Snapshot();
                performanceLogBuilder.AppendLine((snapshot - this.lastRepositorySnapshot).ToString());
                this.lastRepositorySnapshot = snapshot;
            }

            if (this.cache != null)
            {
                var snapshot = this.cache.PerformanceCounter.Snapshot();
                performanceLogBuilder.AppendLine((snapshot - this.lastCacheSnapshot).ToString());
                this.lastCacheSnapshot = snapshot;
            }

            this.logger.LogInformation(performanceLogBuilder.ToString());
        }