Fiddler captures packets to view the response time of the interface

1. Fiddler captures packets to view the response time of the interface

1. You need to visually check the response time behind each interface, instead of looking at the Statistics on the right to check the Overall Elapsed response time

Internet Baidu information

2. Add a piece of code in FiddlerScript on the right, click Save Script to save, and restart Fiddler. TimeTaken/ms is added to the interface data column on the left to display the interface response time

public static BindUIColumn("TimeTaken/ms", 120)
    function TimeTaken(oS: Session):String{
        var sResult = "0";
        var t1_ms = oS.Timers.ClientBeginResponse.ToUniversalTime().Millisecond;
        var t1_m = oS.Timers.ClientBeginResponse.ToUniversalTime().Minute;
        var t1_s = oS.Timers.ClientBeginResponse.ToUniversalTime().Second;
        var t1 = t1_m*60*1000 + t1_s*1000 + t1_ms ;
 
        var t2_ms = oS.Timers.ClientDoneRequest.ToUniversalTime().Millisecond;
        var t2_m = oS.Timers.ClientDoneRequest.ToUniversalTime().Minute;
        var t2_s = oS.Timers.ClientDoneRequest.ToUniversalTime().Second;
        var t2 = t2_m*60*1000 + t2_s*1000 + t2_ms ;
 
        if(t1 >= t2){
            var t3 =  t1 - t2;
            sResult = t3.toString();
        }
        return sResult;
        }

2. Fiddler captures packets to view client request time

 

	//* 显示请求耗时 *//
	function BeginRequestTime(oS: Session)
	{
		if (oS.Timers != null)
		{
			return oS.Timers.ClientBeginRequest.ToString();     
		}
		return String.Empty;
	}

	public static BindUIColumn("TimeTaken")
	function CalcTimingCol(oS: Session){
		var sResult = String.Empty;
		if ((oS.Timers.ServerDoneResponse > oS.Timers.ClientDoneRequest))
		{
			sResult = (oS.Timers.ServerDoneResponse - oS.Timers.ClientDoneRequest).ToString();
		}
		return sResult;
	}	

	//* 显示客户端请求时间 *//
	function StartRequestTime(oS: Session)
	{
		if (oS.Timers != null)
		{
			return oS.Timers.ClientBeginRequest.ToString();     
		}
		return String.Empty;
	}
	public static BindUIColumn("Start")
	function ShowStartRequestTime(oS: Session){
		var sResult = String.Empty;
		if ((oS.Timers.ClientDoneRequest != null))
		{
			sResult = oS.Timers.ClientDoneRequest.ToString();
		}
		return sResult; 

Guess you like

Origin blog.csdn.net/weixin_39118023/article/details/126503365