コード例 #1
0
        public override void Update(IStatsCounter counter, int filter_pid)
        {
            Debug.Assert(counter is StatsCounter || counter is StatsTimer);

            int new_value = 0;

            if (counter is StatsCounter)
            {
                new_value = ((StatsCounter)counter).GetValue(filter_pid);
            }
            else if (counter is StatsTimer)
            {
                new_value = ((StatsTimer)counter).GetValue(filter_pid);
            }

            int old_value = Tag != null ? (int)Tag : 0;
            int delta     = new_value - old_value;

            SetSubItem(SubItems[column_value_index], new_value);
            if (SetSubItem(SubItems[column_delta_index], delta))
            {
                ColorItem(delta);
            }
            Tag = new_value;
        }
コード例 #2
0
        /// <summary>
        /// Create a counter based on an entry
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        private IStatsCounter NameToCounter(int id, string name)
        {
            IStatsCounter rv = null;

            // check if the name has a type encoded
            if (name.Length > 2 && name[1] == ':')
            {
                StatsTableEntry entry = new StatsTableEntry(id, name.Substring(2), table_);
                switch (name[0])
                {
                case 't':
                    rv = new StatsTimer(entry);
                    break;

                case 'c':
                    rv = new StatsCounter(entry);
                    break;
                }
            }
            else
            {
                StatsTableEntry entry = new StatsTableEntry(id, name, table_);
                rv = new StatsCounter(entry);
            }

            return(rv);
        }
コード例 #3
0
 public CounterListViewItem(IStatsCounter ctr, int filter_pid) :
     base(ctr.name)
 {
     Name = ctr.name;
     SubItems.Add(NewSubItem());
     SubItems.Add(NewSubItem());
     Update(ctr, filter_pid);
 }
コード例 #4
0
 public UnboundedLocalCache(Caffeine <K, V> builder, bool isAsync, int concurrencyLevel)
 {
     this.data             = new ConcurrentDictionary <K, V>(concurrencyLevel, builder.InitialCapacity);
     this.statsCounter     = builder.StatsCounter.Get();
     this.removalListener  = builder.RemovalListener;
     this.isRecordingStats = builder.IsRecordingStats;
     this.writer           = builder.Writer;
     this.ticker           = builder.Ticker;
 }
コード例 #5
0
        public RateListViewItem(IStatsCounter ctr, int filter_pid) :
            base(ctr.name)
        {
            StatsCounterRate rate = ctr as StatsCounterRate;

            Name = rate.name;
            SubItems.Add(NewSubItem());
            SubItems.Add(NewSubItem());
            SubItems.Add(NewSubItem());
            Update(ctr, filter_pid);
        }
コード例 #6
0
        public void IncrementBy(IStatsCounter other)
        {
            CacheStats otherStats = other.Snapshot();

            Interlocked.Add(ref hitCount, (long)otherStats.HitCount);
            Interlocked.Add(ref missCount, (long)otherStats.MissCount);
            Interlocked.Add(ref loadSuccessCount, (long)otherStats.LoadSuccessCount);
            Interlocked.Add(ref loadFailureCount, (long)otherStats.LoadFailureCount);
            Interlocked.Add(ref totalLoadTime, (long)otherStats.TotalLoadTime);
            Interlocked.Add(ref evictionCount, (long)otherStats.EvictionCount);
            Interlocked.Add(ref evictionWeight, (long)otherStats.EvictionWeight);
        }
コード例 #7
0
 // If we have two StatsTableEntries with the same name,
 // attempt to upgrade them to a higher level type.
 // Example:  A counter + a timer == a rate!
 private void UpgradeCounter(IStatsCounter old_counter, IStatsCounter counter)
 {
     if (old_counter is StatsCounter && counter is StatsTimer)
     {
         StatsCounterRate rate = new StatsCounterRate(old_counter as StatsCounter,
                                                      counter as StatsTimer);
         counters_.Remove(old_counter);
         counters_.Add(rate);
     }
     else if (old_counter is StatsTimer && counter is StatsCounter)
     {
         StatsCounterRate rate = new StatsCounterRate(counter as StatsCounter,
                                                      old_counter as StatsTimer);
         counters_.Remove(old_counter);
         counters_.Add(rate);
     }
 }
コード例 #8
0
        public override void Update(IStatsCounter counter, int filter_pid)
        {
            Debug.Assert(counter is StatsCounterRate);

            StatsCounterRate new_rate = counter as StatsCounterRate;
            int new_count             = new_rate.GetCount(filter_pid);
            int new_time = new_rate.GetTime(filter_pid);
            int old_avg  = Tag != null ? (int)Tag : 0;
            int new_avg  = new_count > 0 ? (new_time / new_count) : 0;
            int delta    = new_avg - old_avg;

            SetSubItem(SubItems[column_count_index], new_count);
            SetSubItem(SubItems[column_time_index], new_time);
            if (SetSubItem(SubItems[column_avg_index], new_avg))
            {
                ColorItem(delta);
            }
            Tag = new_avg;
        }
コード例 #9
0
        /// <summary>
        /// Updates the UI for a counter.
        /// </summary>
        /// <param name="counter"></param>
        private void UpdateCounter(IStatsCounter counter)
        {
            ListView view;

            // Figure out which list this counter goes into.
            if (counter is StatsCounterRate)
            {
                view = listViewRates;
            }
            else if (counter is StatsCounter || counter is StatsTimer)
            {
                view = listViewCounters;
            }
            else
            {
                return; // Counter type not supported yet.
            }
            // See if the counter is already in the list.
            ListViewItem item = view.Items[counter.name];

            if (item != null)
            {
                // Update an existing counter.
                Debug.Assert(item is StatsCounterListViewItem);
                StatsCounterListViewItem counter_item = item as StatsCounterListViewItem;
                counter_item.Update(counter, filter_pid_);
            }
            else
            {
                // Create a new counter
                StatsCounterListViewItem new_item = null;
                if (counter is StatsCounterRate)
                {
                    new_item = new RateListViewItem(counter, filter_pid_);
                }
                else if (counter is StatsCounter || counter is StatsTimer)
                {
                    new_item = new CounterListViewItem(counter, filter_pid_);
                }
                Debug.Assert(new_item != null);
                view.Items.Add(new_item);
            }
        }
コード例 #10
0
        /// <summary>
        /// Find the counters in the table and insert into the counters_
        /// hash table.
        /// </summary>
        private void FindCounters()
        {
            Debug.Assert(table_.Header.max_counters > 0);

            int index = counter_hi_water_mark_;

            do
            {
                // Find an entry in the table.
                index++;
                long offset = table_.CounterNamesOffset +
                              (index * StatsTable.kMaxCounterNameLength * 2);
                string name = Marshal.PtrToStringUni((IntPtr)offset);
                if (name.Length == 0)
                {
                    continue;
                }

                // Record that we've already looked at this StatsTableEntry.
                counter_hi_water_mark_ = index;

                IStatsCounter counter = NameToCounter(index, name);

                if (counter != null)
                {
                    IStatsCounter old_counter = FindExistingCounter(counter.name);
                    if (old_counter != null)
                    {
                        UpgradeCounter(old_counter, counter);
                    }
                    else
                    {
                        counters_.Add(counter);
                    }
                }
            } while (index < table_.Header.max_counters - 1);
        }
コード例 #11
0
 public CounterListViewItem(IStatsCounter ctr, int filter_pid)
     : base(ctr.name)
 {
     Name = ctr.name;
       SubItems.Add(NewSubItem());
       SubItems.Add(NewSubItem());
       Update(ctr, filter_pid);
 }
コード例 #12
0
        public override void Update(IStatsCounter counter, int filter_pid)
        {
            Debug.Assert(counter is StatsCounter || counter is StatsTimer);

              int new_value = 0;
              if (counter is StatsCounter)
            new_value = ((StatsCounter)counter).GetValue(filter_pid);
              else if (counter is StatsTimer)
            new_value = ((StatsTimer)counter).GetValue(filter_pid);

              int old_value = Tag != null ? (int)Tag : 0;
              int delta = new_value - old_value;
              SetSubItem(SubItems[column_value_index], new_value);
              if (SetSubItem(SubItems[column_delta_index], delta))
            ColorItem(delta);
              Tag = new_value;
        }
コード例 #13
0
 public RateListViewItem(IStatsCounter ctr, int filter_pid)
     : base(ctr.name)
 {
     StatsCounterRate rate = ctr as StatsCounterRate;
       Name = rate.name;
       SubItems.Add(NewSubItem());
       SubItems.Add(NewSubItem());
       SubItems.Add(NewSubItem());
       Update(ctr, filter_pid);
 }
コード例 #14
0
        public override void Update(IStatsCounter counter, int filter_pid)
        {
            Debug.Assert(counter is StatsCounterRate);

              StatsCounterRate new_rate = counter as StatsCounterRate;
              int new_count = new_rate.GetCount(filter_pid);
              int new_time = new_rate.GetTime(filter_pid);
              int old_avg = Tag != null ? (int)Tag : 0;
              int new_avg = new_count > 0 ? (new_time / new_count) : 0;
              int delta = new_avg - old_avg;

              SetSubItem(SubItems[column_count_index], new_count);
              SetSubItem(SubItems[column_time_index], new_time);
              if (SetSubItem(SubItems[column_avg_index], new_avg))
            ColorItem(delta);
              Tag = new_avg;
        }
コード例 #15
0
        /// <summary>
        /// Updates the UI for a counter.
        /// </summary>
        /// <param name="counter"></param>
        private void UpdateCounter(IStatsCounter counter)
        {
            ListView view;

              // Figure out which list this counter goes into.
              if (counter is StatsCounterRate)
            view = listViewRates;
              else if (counter is StatsCounter || counter is StatsTimer)
            view = listViewCounters;
              else
            return; // Counter type not supported yet.

              // See if the counter is already in the list.
              ListViewItem item = view.Items[counter.name];
              if (item != null)
              {
            // Update an existing counter.
            Debug.Assert(item is StatsCounterListViewItem);
            StatsCounterListViewItem counter_item = item as StatsCounterListViewItem;
            counter_item.Update(counter, filter_pid_);
              }
              else
              {
            // Create a new counter
            StatsCounterListViewItem new_item = null;
            if (counter is StatsCounterRate)
              new_item = new RateListViewItem(counter, filter_pid_);
            else if (counter is StatsCounter || counter is StatsTimer)
              new_item = new CounterListViewItem(counter, filter_pid_);
            Debug.Assert(new_item != null);
            view.Items.Add(new_item);
              }
        }
コード例 #16
0
 // If we have two StatsTableEntries with the same name,
 // attempt to upgrade them to a higher level type.
 // Example:  A counter + a timer == a rate!
 private void UpgradeCounter(IStatsCounter old_counter, IStatsCounter counter)
 {
     if (old_counter is StatsCounter && counter is StatsTimer)
       {
     StatsCounterRate rate = new StatsCounterRate(old_counter as StatsCounter,
                                   counter as StatsTimer);
     counters_.Remove(old_counter);
     counters_.Add(rate);
       }
       else if (old_counter is StatsTimer && counter is StatsCounter)
       {
     StatsCounterRate rate = new StatsCounterRate(counter as StatsCounter,
                                  old_counter as StatsTimer);
     counters_.Remove(old_counter);
     counters_.Add(rate);
       }
 }
コード例 #17
0
 /// <summary>
 /// Update the ListViewItem given a new counter value.
 /// </summary>
 /// <param name="counter"></param>
 /// <param name="filter_pid"></param>
 public virtual void Update(IStatsCounter counter, int filter_pid)
 {
 }
コード例 #18
0
 /// <summary>
 /// Update the ListViewItem given a new counter value.
 /// </summary>
 /// <param name="counter"></param>
 /// <param name="filter_pid"></param>
 public virtual void Update(IStatsCounter counter, int filter_pid)
 {
 }
コード例 #19
0
 public GuardedStatsCounter(IStatsCounter @delegate)
 {
     this.@delegate = @delegate;
 }
 public BoundedLocalCacheStrongKeyStrongValueStatistics(Caffeine <K, V> builder, CacheLoader <K, V> loader, bool isAsync)
     : base(builder, loader, isAsync)
 {
     statsCounter = builder.StatsCounter.Get();
 }