コード例 #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)
            {
                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
        void AddBenchStats(StringBuilder log)
        {
            log.AppendLine("======CachedCoinView Bench======");

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

            var snapShot = this.performanceCounter.Snapshot();

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

            this.latestPerformanceSnapShot = snapShot;
        }