public void Process() { LongestPrefix = 0; foreach (KeyValuePair <string, SourceFunction> pair in Funcs) { SourceFunction func = pair.Value; List <Prefix> prefixes = new List <Prefix>(); float sum = 0.0f; int maxHit = 0; int maxHitLine = 0; foreach (KeyValuePair <int, int> hit in func.Hits) { prefixes.Add(new Prefix(hit.Key - 1, hit.Value)); sum += (float)(hit.Value); if (hit.Value > maxHit) { maxHitLine = hit.Key; maxHit = hit.Value; } } func.MaxHitLine = maxHitLine; foreach (Prefix prefix in prefixes) { prefix.Text = String.Format("{0:00.00}%", 100.0f * (float)(prefix.Hits) / sum); if (prefix.Text.Length > LongestPrefix) { LongestPrefix = prefix.Text.Length; } } PrefixLines.AddRange(prefixes); } PrefixLines.Sort(Prefix.Compare); }
public void AddSource(SourceFunction sf) { if (sf != null) { try { sf.Init(); } catch (Exception ex) { Logger.Log.Error(true, "SourceFuntion:", ex); } sf.Context = new SourceContext(); sf.Context.CollectHandler += SourceFunction_CollectHandler; Thread thread = new Thread(new ParameterizedThreadStart(sf.Run)); thread.IsBackground = true; thread.Name = "SourceFunction:" + sf.GetHashCode().ToString(); SourceFunctionThread sourceFunctionThread = new SourceFunctionThread(sf, thread); SourceFunctionThreads.Add(sourceFunctionThread); } }
internal SourceFunctionThread(SourceFunction sf, Thread t) { SourceFunction = sf; Thread = t; }