コード例 #1
0
        public RequestNode(string path, RequestNode parent = null)
        {
            _parent = parent;

            Path       = path;
            Children   = new Dictionary <string, RequestNode>();
            Statuses   = Enumerable.Empty <int>();
            Verbs      = Enumerable.Empty <string>();
            Hosts      = Enumerable.Empty <string>();
            MinElapsed = TimeSpan.MinValue;
        }
コード例 #2
0
        public RequestNode GetChild(string path)
        {
            RequestNode node;

            if (!Children.TryGetValue(path, out node))
            {
                node           = new RequestNode(path, this);
                Children[path] = node;
            }

            return(node);
        }
コード例 #3
0
        public async Task <RequestNode> GetRequestTree(long position)
        {
            var root = new RequestNode("/");

            foreach (var item in (await GetRecentRequests(position)).Items)
            {
                var parts = item.OriginUrl.PathAndQuery.Split('/');

                var parent = root;

                foreach (var path in parts.Where(p => !string.IsNullOrEmpty(p)))
                {
                    var node = parent.GetChild(path);

                    node.AverageSizeKb = ((node.RequestCount * node.AverageSizeKb)
                                          + ((double)item.ResponseSize / 1024)) / (++node.RequestCount);

                    node.RegisterStatus(item.Status, item.HttpVerb);
                    node.RegisterHost(item.OriginUrl.Host);

                    if (item.Elapsed > node.MaxElapsed)
                    {
                        node.MaxElapsed = item.Elapsed;
                    }

                    if (item.Elapsed < node.MinElapsed || node.MinElapsed == TimeSpan.MinValue)
                    {
                        node.MinElapsed = item.Elapsed;
                    }

                    parent = node;
                }
            }

            return(root);
        }