Beispiel #1
0
 public BlockStoreStats(BlockRepository blockRepository, BlockStoreCache blockStoreCache)
 {
     this.repository             = blockRepository;
     this.cache                  = blockStoreCache;
     this.lastRepositorySnapshot = this.repository?.PerformanceCounter.Snapshot();
     this.lastCacheSnapshot      = this.cache?.PerformanceCounter.Snapshot();
 }
Beispiel #2
0
        public BlockStoreRepositoryPerformanceSnapshot Snapshot()
        {
#if !(PORTABLE || NETCORE)
            Thread.MemoryBarrier();
#endif
            var snap = new BlockStoreRepositoryPerformanceSnapshot(this.RepositoryHitCount, this.RepositoryMissCount, this.RepositoryDeleteCount, this.RepositoryInsertCount)
            {
                Start = this.Start,
                Taken = DateTime.UtcNow
            };
            return(snap);
        }
Beispiel #3
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;
            }

            Logs.BlockStore.LogInformation(performanceLogBuilder.ToString());
        }