Example #1
0
        private List<HarFile.Stat> processStat(List<HarFile.Stat> statlist, HarFile.Entry entry, string item)
        {
            int code = entry.response.status / 100;
            HarFile.SimpleEntry se = new HarFile.SimpleEntry();
            se.responseSize = entry.response.content.size;
            se.time = entry.time;
            se.timestamp = entry.startedDateTime.ToString();
            se.url = entry.request.url;
            //find existing stat
            if (statlist.Where(x => x.item == item).Count() > 0)
            {
                HarFile.Stat match = statlist.Where(x => x.item == item).ElementAt(0);
                statlist.RemoveAll(x => x.item == item);
                match.count++;
                switch (code)
                {
                    case 2:
                        match.count200++;
                        break;
                    case 4:
                        match.count400++;
                        break;
                    case 5:
                        match.count500++;
                        break;
                    default:
                        break;
                }
                match.entries.Add(se);
                match.avgBlocked += Math.Max(entry.timings.blocked, 0);
                match.longestBlocked = Math.Max(match.longestBlocked, entry.timings.blocked);
                match.avgConnect += Math.Max(entry.timings.connect, 0);
                match.longestConnect = Math.Max(match.longestConnect, entry.timings.connect);
                match.avgDNS += Math.Max(entry.timings.dns, 0);
                match.longestDNS = Math.Max(match.longestDNS, entry.timings.dns);
                match.avgDownload += Math.Max(entry.timings.receive, 0);
                match.longestDownload = Math.Max(match.longestDownload, entry.timings.receive);
                match.avgLoad += Math.Max(entry.time, 0);
                match.longestLoad = Math.Max(match.longestLoad, entry.time);
                match.avgSend += Math.Max(entry.timings.send, 0);
                match.longestSend = Math.Max(match.longestSend, entry.timings.send);
                match.avgSSL += Math.Max(entry.timings.ssl, 0);
                match.longestSSL = Math.Max(match.longestSSL, entry.timings.ssl);
                match.avgWait += Math.Max(entry.timings.wait, 0);
                match.longestWait = Math.Max(match.longestWait, entry.timings.wait);
                statlist.Add(match);
                return statlist;
            }
            HarFile.Stat newStat = new HarFile.Stat();
            newStat.entries = new List<HarFile.SimpleEntry>();
            newStat.item = item;
            newStat.count = 1;

            switch (code)
            {
                case 2:
                    newStat.count200 = 1;
                    newStat.count400 = 0;
                    newStat.count500 = 0;
                    break;
                case 4:
                    newStat.count200 = 0;
                    newStat.count400 = 1;
                    newStat.count500 = 0;
                    break;
                case 5:
                    newStat.count200 = 0;
                    newStat.count400 = 0;
                    newStat.count500 = 1;
                    break;
                default:
                    break;
            }
            newStat.entries.Add(se);
            newStat.avgLoad = Math.Max(entry.time, 0);
            newStat.longestLoad = Math.Max(entry.time, 0);
            newStat.avgBlocked = Math.Max(entry.timings.blocked, 0);
            newStat.longestBlocked = Math.Max(entry.timings.blocked, 0);
            newStat.avgDNS = Math.Max(entry.timings.dns, 0);
            newStat.longestDNS = Math.Max(entry.timings.dns, 0);
            newStat.avgConnect = Math.Max(entry.timings.connect, 0);
            newStat.longestConnect = Math.Max(entry.timings.connect, 0);
            newStat.avgSSL = Math.Max(entry.timings.ssl, 0);
            newStat.longestSSL = Math.Max(entry.timings.ssl, 0);
            newStat.avgSend = Math.Max(entry.timings.send, 0);
            newStat.longestSend = Math.Max(entry.timings.send, 0);
            newStat.avgWait = Math.Max(entry.timings.wait, 0);
            newStat.longestWait = Math.Max(entry.timings.wait, 0);
            newStat.avgDownload = Math.Max(entry.timings.receive, 0);
            newStat.longestDownload = Math.Max(entry.timings.receive, 0);
            statlist.Add(newStat);
            return statlist;
        }
Example #2
0
        private List <HarFile.Stat> processStat(List <HarFile.Stat> statlist, HarFile.Entry entry, string item)
        {
            int code = entry.response.status / 100;

            HarFile.SimpleEntry se = new HarFile.SimpleEntry();
            se.responseSize = entry.response.content.size;
            se.time         = entry.time;
            se.timestamp    = entry.startedDateTime.ToString();
            se.url          = entry.request.url;
            //find existing stat
            if (statlist.Where(x => x.item == item).Count() > 0)
            {
                HarFile.Stat match = statlist.Where(x => x.item == item).ElementAt(0);
                statlist.RemoveAll(x => x.item == item);
                match.count++;
                switch (code)
                {
                case 2:
                    match.count200++;
                    break;

                case 4:
                    match.count400++;
                    break;

                case 5:
                    match.count500++;
                    break;

                default:
                    break;
                }
                match.entries.Add(se);
                match.avgBlocked     += Math.Max(entry.timings.blocked, 0);
                match.longestBlocked  = Math.Max(match.longestBlocked, entry.timings.blocked);
                match.avgConnect     += Math.Max(entry.timings.connect, 0);
                match.longestConnect  = Math.Max(match.longestConnect, entry.timings.connect);
                match.avgDNS         += Math.Max(entry.timings.dns, 0);
                match.longestDNS      = Math.Max(match.longestDNS, entry.timings.dns);
                match.avgDownload    += Math.Max(entry.timings.receive, 0);
                match.longestDownload = Math.Max(match.longestDownload, entry.timings.receive);
                match.avgLoad        += Math.Max(entry.time, 0);
                match.longestLoad     = Math.Max(match.longestLoad, entry.time);
                match.avgSend        += Math.Max(entry.timings.send, 0);
                match.longestSend     = Math.Max(match.longestSend, entry.timings.send);
                match.avgSSL         += Math.Max(entry.timings.ssl, 0);
                match.longestSSL      = Math.Max(match.longestSSL, entry.timings.ssl);
                match.avgWait        += Math.Max(entry.timings.wait, 0);
                match.longestWait     = Math.Max(match.longestWait, entry.timings.wait);
                statlist.Add(match);
                return(statlist);
            }
            HarFile.Stat newStat = new HarFile.Stat();
            newStat.entries = new List <HarFile.SimpleEntry>();
            newStat.item    = item;
            newStat.count   = 1;

            switch (code)
            {
            case 2:
                newStat.count200 = 1;
                newStat.count400 = 0;
                newStat.count500 = 0;
                break;

            case 4:
                newStat.count200 = 0;
                newStat.count400 = 1;
                newStat.count500 = 0;
                break;

            case 5:
                newStat.count200 = 0;
                newStat.count400 = 0;
                newStat.count500 = 1;
                break;

            default:
                break;
            }
            newStat.entries.Add(se);
            newStat.avgLoad         = Math.Max(entry.time, 0);
            newStat.longestLoad     = Math.Max(entry.time, 0);
            newStat.avgBlocked      = Math.Max(entry.timings.blocked, 0);
            newStat.longestBlocked  = Math.Max(entry.timings.blocked, 0);
            newStat.avgDNS          = Math.Max(entry.timings.dns, 0);
            newStat.longestDNS      = Math.Max(entry.timings.dns, 0);
            newStat.avgConnect      = Math.Max(entry.timings.connect, 0);
            newStat.longestConnect  = Math.Max(entry.timings.connect, 0);
            newStat.avgSSL          = Math.Max(entry.timings.ssl, 0);
            newStat.longestSSL      = Math.Max(entry.timings.ssl, 0);
            newStat.avgSend         = Math.Max(entry.timings.send, 0);
            newStat.longestSend     = Math.Max(entry.timings.send, 0);
            newStat.avgWait         = Math.Max(entry.timings.wait, 0);
            newStat.longestWait     = Math.Max(entry.timings.wait, 0);
            newStat.avgDownload     = Math.Max(entry.timings.receive, 0);
            newStat.longestDownload = Math.Max(entry.timings.receive, 0);
            statlist.Add(newStat);
            return(statlist);
        }