Exemplo n.º 1
0
        public static IList <OccuranceBucket> RecursiveAnalyze(IList <Pair <long, EventBean[]> > occurances,
                                                               long[] granularities,
                                                               int level,
                                                               long start,
                                                               long end)
        {
            // form buckets
            long granularity = granularities[level];
            IDictionary <int, OccuranceIntermediate> intermediates = new LinkedHashMap <int, OccuranceIntermediate>();
            int countBucket = 0;

            for (long offset = start; offset < end; offset += granularity)
            {
                var intermediate = new OccuranceIntermediate(offset, offset + granularity - 1);
                intermediates.Put(countBucket, intermediate);
                countBucket++;
            }

            // sort into bucket
            foreach (var entry in occurances)
            {
                long time   = entry.First;
                long delta  = time - start;
                var  bucket = (int)(delta / granularity);
                OccuranceIntermediate intermediate = intermediates.Get(bucket);
                intermediate.Items.Add(entry);
            }

            // report each bucket6
            IList <OccuranceBucket> buckets = new List <OccuranceBucket>();

            foreach (var pair in intermediates)
            {
                OccuranceIntermediate inter  = pair.Value;
                OccuranceBucket       bucket = GetBucket(inter);
                buckets.Add(bucket);

                // for buckets within buckets
                if ((level < (granularities.Length - 1) && (inter.Items.IsNotEmpty())))
                {
                    bucket.InnerBuckets = RecursiveAnalyze(inter.Items, granularities, level + 1, inter.Low, inter.High);
                }
            }

            return(buckets);
        }
Exemplo n.º 2
0
        private static void Render(TextWriter writer, int indent, String identifier, long start, OccuranceBucket bucket)
        {
            double lowRelative  = (bucket.Low - start) / 1d / OccuranceAnalyzer.MSEC_DIVISIOR;
            double highRelative = (bucket.High - start) / 1d / OccuranceAnalyzer.MSEC_DIVISIOR;

            AddIndent(writer, indent);
            writer.WriteLine("{0} [{1}, {2}] {3} entries {4}",
                             identifier,
                             lowRelative,
                             highRelative,
                             bucket.CountTotal,
                             bucket.CountEntry);

            int count = 0;

            foreach (OccuranceBucket inner in bucket.InnerBuckets)
            {
                Render(writer, indent + 1, identifier + "." + count, bucket.Low, inner);
                count++;
            }
        }