-3

我已经构建了一个加载 URL 并显示加载时间的网络加载器。我的问题是,如何在此站点中添加虚拟用户以同时执行多个用户测试以对所选 URL 进行压力测试。

<html>
<head> 
    <script type="text/javascript">  
        beforeload = (new Date()).getTime();
        function pageloadingtime()
        { 
            afterload = (new Date()).getTime();
            seconds = (afterload-beforeload)/1000;
            document.getElementById("loadingtime").innerHTML = "<font color='red'>(You Page Load took " + seconds + " second(s).)</font>";
        }
    </script>
    <title>load time</title>
</head>

<body>   
    <div id="loadingtime"></div>
    <script type="text/javascript">  
        function Reload() {
            beforeload = (new Date()).getTime();
            var f = document.getElementById('iFrame');
            f.src = f.src;
        }    
    </script>

    <script type="text/javascript">
        function submitStuff(){
            document.getElementById('iFrame').src = 'http://' + document.theForm.url.value;
            return false ;
        }
    </script>
    <form name="theForm" method="post" onsubmit="return submitStuff();">
        <input name="url" value="" >
        <input type="submit" name="submitButton" value="Submit/Refresh" onclick="Reload();">
    </form>
    <iframe id="iFrame" width="1320" height="540" src="http://www.default.com" onload="pageloadingtime();"></iframe>
</body>
</html>
4

1 回答 1

1

您需要使用一些软件对页面运行压力测试。我建议 Selenium - http://docs.seleniumhq.org/。它很容易设置和使用。它肯定会做你需要的。

于 2013-08-13T09:08:14.423 回答