Ejemplo n.º 1
0
 public BondDynamicDriver()
 {
     _typeCache = new TypeCache();
 }
Ejemplo n.º 2
0
        public Dictionary<Type, EventStatistics> GetTypeStatistics(TypeCache typeCache, string inputFile)
        {
            var statsPerType = new Dictionary<Type, EventStatistics>();

            if (string.IsNullOrWhiteSpace(inputFile))
            {
                throw new ArgumentException("inputFile");
            }

            Console.WriteLine("Getting Statistics...");

            var rawCount = from events in BinaryEtwObservable.FromSequentialFiles(inputFile)
                group events by events.PayloadId
                    into eventTypes
                    from all in
                        eventTypes.Aggregate(
                            new { EventCount = (long)0, Bytes = (long)0, minTime = long.MaxValue, maxTime = 0L },
                            (ac, events) =>
                            new
                            {
                                EventCount = ac.EventCount + 1,
                                Bytes = ac.Bytes + events.EventPayloadLength,
                                minTime = Math.Min(ac.minTime, events.ReceiveFileTimeUtc),
                                maxTime = Math.Max(ac.maxTime, events.ReceiveFileTimeUtc)
                            })
                    select new { ManifestId = eventTypes.Key, all.EventCount, all.Bytes, all.minTime, all.maxTime };

            var counts = rawCount.ToEnumerable().ToArray();

            foreach (var c in counts)
            {
                var manifest = typeCache.Manifests
                    .FirstOrDefault(m => string.Equals(m.ManifestId, c.ManifestId, StringComparison.OrdinalIgnoreCase));

                if (manifest != null)
                {
                    var line = manifest.Manifest
                        .Split('\n').LastOrDefault(l => l.Trim().StartsWith(@"struct ", StringComparison.OrdinalIgnoreCase));

                    var className = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1].Trim();

                    var type = typeCache.Types.FirstOrDefault(t => t.Name == className);

                    var minDateTime = DateTime.FromFileTimeUtc(c.minTime);
                    var maxDateTime = DateTime.FromFileTimeUtc(c.maxTime);
                    var duration = (maxDateTime - minDateTime).TotalSeconds;
                    if (Math.Abs(this.duration) < 0.01) this.duration = 1;

                    var stats = new EventStatistics
                    {
                        AverageByteSize = c.Bytes / c.EventCount,
                        ByteSize = c.Bytes,
                        EventCount = c.EventCount,
                        EventsPerSecond = c.EventCount / duration
                    };

                    statsPerType.Add(type, stats);
                }
            }

            return statsPerType;
        }
Ejemplo n.º 3
0
 public BondDynamicDriver()
 {
     _typeCache = new TypeCache();
 }