问题描述
我正在尝试编写一个脚本,该脚本将测试两个 URl 之间的页面速度并提供一些有用的数据。我正在使用 K6 性能测试套件来执行此操作,我正在使用他们的框架在 javascript 中编写脚本。
我很好奇我将如何构建一个比较 2 个 URL 速度的测试。
Example:
Page 1 would be `www.oldsite.com/test` -- 20ms to load
Page 2 would be `www.newsite.com/test` -- 17ms to load
我这样做是因为我们正在更新我们的网站,并希望在开发阶段对速度和性能进行一些基准测试。
下面是一些我必须用来测试的代码。
let response;
var sendingRecievingTrend = new Trend("sending_recieving_time");
function requestPage(url) {
let response = http.get(url,{
headers: {
"Upgrade-Insecure-Requests": "1",Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
}
});
sendingRecievingTrend.add(response.timings.sending + response.timings.receiving);
check(response,{ "Response return 200 HTTP Status Code": r => r.status === 200 });
return response;
}
group(`Old Mobile Products Page - ${config.oldMobileUri}/products/`,function () {
response = requestPage(`${config.oldMobileUri}/products/`);
});
group(`New Mobile Products Page - ${config.newMobileUri}/products/`,function () {
response = requestPage(`${config.newMobileUri}/products/`);
});
但是,如果我这样做,那么我相信我只是所有这些 group tests
花费的总时间的平均值。我正在寻找我测试的每个网址的单独统计信息。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)