Beispiel #1
0
        public override void Apply(Counters counters)
        {
            _counters = counters;

              for (var i = 0; i < _count.GetValue(X); i++)
              {
            var counter = _counterFactory().Initialize(Game);
            counters.Add(counter);

            _addedCounters.Add(counter);
              }
        }
Beispiel #2
0
 public void IncrementCount(string CountName)
 {
     lock (DataLock)
     {
         if (Counters.ContainsKey(CountName))
         {
             Counters[CountName]++;
         }
         else
         {
             Counters.Add(CountName, 1);
         }
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="DistributedCacheSessionTracer" /> class.
        /// </summary>
        public DistributedCacheSessionTracer(ILogger logger, string name)
            : base(logger, name)
        {
            CallCounters.Add(_getSelectorsCallCounter         = new CallCounter(GetSelectorsCallName));
            CallCounters.Add(_addSelectorsCallCounter         = new CallCounter(AddSelectorsCallName));
            CallCounters.Add(_invalidateCacheEntryCallCounter = new CallCounter(InvalidateCacheEntryCallName));
            CallCounters.Add(_getContentHashListCallCounter   = new CallCounter(GetContentHashListCallName));
            CallCounters.Add(_addContentHashListCallCounter   = new CallCounter(AddContentHashListCallName));

            Counters.Add(_getContentHashListFetchedDistributed = new Counter(GetContentHashListFetchedDistributedName));
            Counters.Add(_getContentHashListFetchedBacking     = new Counter(GetContentHashListFetchedBackingName));
            Counters.Add(_getSelectorsFetchedDistributed       = new Counter(GetSelectorsFetchedDistributedName));
            Counters.Add(_getSelectorsFetchedBacking           = new Counter(GetSelectorsFetchedBackingName));
        }
Beispiel #4
0
        public static void countwords(string[] words)
        {
            foreach (var word in words)
            {
                string sortedWord = String.Concat(word.OrderBy(c => c));

                if (!Counters.ContainsKey(sortedWord))
                {
                    Counters.Add(sortedWord, 0);
                    wordsToABC.Add(word, sortedWord);
                }

                Counters[sortedWord] += 1;
            }
        }
Beispiel #5
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="SQLiteMemoizationStoreTracer"/> class.
        /// </summary>
        /// <param name="logger">Logger</param>
        /// <param name="name">Tracer Name</param>
        public SQLiteMemoizationStoreTracer(ILogger logger, string name)
            : base(logger, name)
        {
            Counters.Add(_masterDbCorruptionCount       = new Counter("MasterDbCorruptionCount"));
            Counters.Add(_backupDbCorruptionCount       = new Counter("BackupDbCorruptionCount"));
            Counters.Add(_sqliteMarkerCreatedCount      = new Counter("SQLiteMarkerCreated"));
            Counters.Add(_sqliteMarkerCreateFailedCount = new Counter("SQLiteMarkerCreateFailed"));
            Counters.Add(_sqliteMarkerDeletedCount      = new Counter("SQLiteMarkerDeleted"));
            Counters.Add(_sqliteMarkerDeleteFailedCount = new Counter("SQLiteMarkerDeleteFailed"));
            Counters.Add(_sqliteMarkerLeftBehindCount   = new Counter("SQLiteMarkerLeftBehind"));
            Counters.Add(_sqliteIntegrityCheckSucceeded = new Counter("SQLiteIntegrityCheckSucceeded"));
            Counters.Add(_sqliteIntegrityCheckFailed    = new Counter("SQLiteIntegrityCheckFailed"));

            CallCounters.Add(_sqliteIntegrityCheckCallCounter = new CallCounter(SQLiteIntegrityCheckCallName));

            _sqliteDatabaseSize = -1;
        }
Beispiel #6
0
        public void Init()
        {
            using (var repository = new GrillBotRepository(Config))
            {
                var data = repository.ChannelStats.GetChannelStatistics();

                foreach (var stat in data)
                {
                    Counters.Add(stat.SnowflakeID, stat);
                }
            }

            var syncPeriod = GrillBotService.DatabaseSyncPeriod;

            DbSyncTimer = new Timer(SyncTimerCallback, null, syncPeriod, syncPeriod);
            LoggingService.Write($"Channel statistics loaded from database. (Rows: {Counters.Count})");
        }
Beispiel #7
0
    // used by net interface for syncing
    public void RecieveCountersPlaced(CounterType counterType, int newCounters)
    {
        int currentCounters = Counters.AmountOf(counterType);

        if (currentCounters > newCounters)
        {
            Counters.Remove(counterType, currentCounters - newCounters);
        }
        else if (currentCounters < newCounters)
        {
            Counters.Add(counterType, newCounters - currentCounters);
        }
        else
        {
            Debug.Log("Trying to set counters to a value it's already set to. This shouldn't happen under normal circumstances");
        }
    }
Beispiel #8
0
        private void EventPostProcess(string name)
        {
            AppLogger.LogInformation($"Logger event {name} triggered.");

            if (!Counters.ContainsKey(name))
            {
                Counters.Add(name, 1);
            }
            else
            {
                Counters[name]++;
            }

            lock (LastEventLock)
            {
                LastEvent   = name;
                LastEventAt = DateTime.UtcNow;
            }
        }
Beispiel #9
0
 public void LoadConfig()
 {
     try
     {
         if (_cfg.AppSettings.Settings.AllKeys.Contains(ConfigConstants.Counters) == true)
         {
             _counters.Clear();
             PerfCounters cc = PerfCounters.Load(_cfg.AppSettings.Settings[ConfigConstants.Counters].Value);
             if (cc != null)
             {
                 cc.Counters.ForEach(x => Counters.Add(x));
             }
         }
         this.countersGrid.ItemsSource   = this.Counters;
         this.countersGrid.SelectedIndex = 0;
     }
     catch (Exception ex)
     {
         Nagios.Net.Client.Log.WriteLog(string.Format("{0}\n{1}", ex.Message, ex.StackTrace), true);
     }
 }
 public void AddCounter <T>(Counter <T> counter) where T : IInspectionObject
 {
     Counters.Add(counter);
 }
Beispiel #11
0
        /// <include file='doc\PerformanceCounterInstaller.uex' path='docs/doc[@for="PerformanceCounterInstaller.CopyFromComponent"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public override void CopyFromComponent(IComponent component)
        {
            if (!(component is PerformanceCounter))
            {
                throw new ArgumentException(Res.GetString(Res.NotAPerformanceCounter));
            }

            PerformanceCounter counter = (PerformanceCounter)component;

            if (counter.CategoryName == null || counter.CategoryName.Length == 0)
            {
                throw new ArgumentException(Res.GetString(Res.IncompletePerformanceCounter));
            }

            if (Counters.Count > 0 && !CategoryName.Equals(counter.CategoryName))
            {
                throw new ArgumentException(Res.GetString(Res.NewCategory));
            }

            PerformanceCounterType counterType = PerformanceCounterType.NumberOfItems32;
            string counterHelp = string.Empty;

            if (CategoryName == null || string.Empty.Equals(CategoryName))
            {
                CategoryName = counter.CategoryName;
                if (Environment.OSVersion.Platform == PlatformID.Win32NT)
                {
                    string machineName = counter.MachineName;

                    if (PerformanceCounterCategory.Exists(CategoryName, machineName))
                    {
                        string      keyPath = ServicePath + "\\" + CategoryName + "\\Performance";
                        RegistryKey key     = null;
                        try {
                            if (machineName == "." || String.Compare(machineName, SystemInformation.ComputerName, true, CultureInfo.InvariantCulture) == 0)
                            {
                                key = Registry.LocalMachine.OpenSubKey(keyPath);
                            }
                            else
                            {
                                RegistryKey baseKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, "\\\\" + machineName);
                                key = baseKey.OpenSubKey(keyPath);
                            }

                            if (key == null)
                            {
                                throw new ArgumentException(Res.GetString(Res.NotCustomPerformanceCategory));
                            }

                            object systemDllName = key.GetValue("Library");
                            if (systemDllName == null || !(systemDllName is string) || String.Compare((string)systemDllName, PerfShimName, true, CultureInfo.InvariantCulture) != 0)
                            {
                                throw new ArgumentException(Res.GetString(Res.NotCustomPerformanceCategory));
                            }

                            PerformanceCounterCategory pcat = new PerformanceCounterCategory(CategoryName, machineName);
                            CategoryHelp = pcat.CategoryHelp;
                            if (pcat.CounterExists(counter.CounterName))
                            {
                                counterType = counter.CounterType;
                                counterHelp = counter.CounterHelp;
                            }
                        }
                        finally {
                            if (key != null)
                            {
                                key.Close();
                            }
                        }
                    }
                }
            }

            CounterCreationData data = new CounterCreationData(counter.CounterName, counterHelp, counterType);

            Counters.Add(data);
        }
Beispiel #12
0
        public override ICounter <E> Score()
        {
            ICounter <E> currentPatternWeights4Label = new ClassicCounter <E>();
            ICounter <E> pos_i   = new ClassicCounter <E>();
            ICounter <E> neg_i   = new ClassicCounter <E>();
            ICounter <E> unlab_i = new ClassicCounter <E>();

            foreach (KeyValuePair <E, ClassicCounter <CandidatePhrase> > en in negPatternsandWords4Label.EntrySet())
            {
                neg_i.SetCount(en.Key, en.Value.Size());
            }
            foreach (KeyValuePair <E, ClassicCounter <CandidatePhrase> > en_1 in unLabeledPatternsandWords4Label.EntrySet())
            {
                unlab_i.SetCount(en_1.Key, en_1.Value.Size());
            }
            foreach (KeyValuePair <E, ClassicCounter <CandidatePhrase> > en_2 in patternsandWords4Label.EntrySet())
            {
                pos_i.SetCount(en_2.Key, en_2.Value.Size());
            }
            ICounter <E> all_i = Counters.Add(pos_i, neg_i);

            all_i.AddAll(unlab_i);
            //    for (Entry<Integer, ClassicCounter<String>> en : allPatternsandWords4Label
            //        .entrySet()) {
            //      all_i.setCount(en.getKey(), en.getValue().size());
            //    }
            ICounter <E> posneg_i = Counters.Add(pos_i, neg_i);
            ICounter <E> logFi    = new ClassicCounter <E>(pos_i);

            Counters.LogInPlace(logFi);
            if (patternScoring.Equals(GetPatternsFromDataMultiClass.PatternScoring.RlogF))
            {
                currentPatternWeights4Label = Counters.Product(Counters.Division(pos_i, all_i), logFi);
            }
            else
            {
                if (patternScoring.Equals(GetPatternsFromDataMultiClass.PatternScoring.RlogFPosNeg))
                {
                    Redwood.Log("extremePatDebug", "computing rlogfposneg");
                    currentPatternWeights4Label = Counters.Product(Counters.Division(pos_i, posneg_i), logFi);
                }
                else
                {
                    if (patternScoring.Equals(GetPatternsFromDataMultiClass.PatternScoring.RlogFUnlabNeg))
                    {
                        Redwood.Log("extremePatDebug", "computing rlogfunlabeg");
                        currentPatternWeights4Label = Counters.Product(Counters.Division(pos_i, Counters.Add(neg_i, unlab_i)), logFi);
                    }
                    else
                    {
                        if (patternScoring.Equals(GetPatternsFromDataMultiClass.PatternScoring.RlogFNeg))
                        {
                            Redwood.Log("extremePatDebug", "computing rlogfneg");
                            currentPatternWeights4Label = Counters.Product(Counters.Division(pos_i, neg_i), logFi);
                        }
                        else
                        {
                            if (patternScoring.Equals(GetPatternsFromDataMultiClass.PatternScoring.YanGarber02))
                            {
                                ICounter <E> acc            = Counters.Division(pos_i, Counters.Add(pos_i, neg_i));
                                double       thetaPrecision = 0.8;
                                Counters.RetainAbove(acc, thetaPrecision);
                                ICounter <E> conf = Counters.Product(Counters.Division(pos_i, all_i), logFi);
                                foreach (E p in acc.KeySet())
                                {
                                    currentPatternWeights4Label.SetCount(p, conf.GetCount(p));
                                }
                            }
                            else
                            {
                                if (patternScoring.Equals(GetPatternsFromDataMultiClass.PatternScoring.LinICML03))
                                {
                                    ICounter <E> acc            = Counters.Division(pos_i, Counters.Add(pos_i, neg_i));
                                    double       thetaPrecision = 0.8;
                                    Counters.RetainAbove(acc, thetaPrecision);
                                    ICounter <E> conf = Counters.Product(Counters.Division(Counters.Add(pos_i, Counters.Scale(neg_i, -1)), all_i), logFi);
                                    foreach (E p in acc.KeySet())
                                    {
                                        currentPatternWeights4Label.SetCount(p, conf.GetCount(p));
                                    }
                                }
                                else
                                {
                                    throw new Exception("not implemented " + patternScoring + " . check spelling!");
                                }
                            }
                        }
                    }
                }
            }
            return(currentPatternWeights4Label);
        }
Beispiel #13
0
 public void AddCounter(int counterLength)
 {
     Counters.Add(counterLength);
 }
Beispiel #14
0
 public void GiveCounter(Counter counter)
 {
     Counters.Add(counter);
 }
        public override void Init(CallMethodInfo info, string configString)
        {
            base.Init(info, configString);

            Counters.Add(_counter = CreateCounter(info) ?? CreateCounterInternal(info));
        }
Beispiel #16
0
        public RateOfCountsPerformanceCounter(string counterName)
        {
            CounterName = counterName;

            Counters.Add(this);
        }
Beispiel #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ServiceClientContentSessionTracer"/> class.
 /// </summary>
 public ServiceClientContentSessionTracer(string name)
     : base(name)
 {
     Counters.Add(_clientWaitForServer = new Counter(ClientWaitForServerName));
 }