loadrunner测试下载服务器性能

来源:互联网 发布:网络电影发行 编辑:程序博客网 时间:2024/05/10 04:45

服务器是用nginx做的一个重定向下载:

Action(){     int returnCode;    float fFileDownloadSize, fFileDownloadTime, fFileDownloadRate;    lr_start_transaction("TvProgram");    web_submit_data("TvProgram",      "Action=http://172.21.13.72/iPG/T-nsp/TvProgram.do?",      "Method=GET",      "RecContentType=text/html",      "Mode=HTTP",      ITEMDATA,     "Name=userId","Value=6500841",ENDITEM,     "Name=channelId","Value={channelId}",ENDITEM,     "Name=startDate","Value=2017-10-14",ENDITEM,     "Name=endDate","Value=2017-10-21",ENDITEM,     "Name=gzip","Value=1",ENDITEM,     LAST );    returnCode = web_get_int_property(HTTP_INFO_RETURN_CODE);         fFileDownloadSize = (web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE)/1024.); //in kilobytes    fFileDownloadTime = (web_get_int_property(HTTP_INFO_DOWNLOAD_TIME)/1000.); //in seconds    fFileDownloadRate = fFileDownloadSize/fFileDownloadTime; //in KB/s    if (returnCode!=200||fFileDownloadSize<5||fFileDownloadTime>0.5)    {      lr_output_message("error!returnCode=%d,Size of download was %.0f kilobytes; Time of download was %.3f seconds",returnCode, fFileDownloadSize, fFileDownloadTime);      lr_end_transaction("TvProgram" ,LR_FAIL);    }    else    {         lr_end_transaction("TvProgram" ,LR_PASS);    }      return 0;}