利用ajax,canvas实现的测试php程序占用内存的代码
receive.php
<?php
$array["time"]=time();
$array["memory"]=memory_get_usage();
echo json_encode($array);
?>
ceshi.php
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(function(){
var dddd=null;
var c=document.getElementById("myCanvas");
var cxt=c.getContext("2d");
cxt.moveTo(0,0);
ss();
function ss(){
$.ajax({
type: "POST",
url: "http://localhost/ceshi/memory/receive.php",
dataType: "json",
data: "id=1",
success: function(data){
dddd=data;
cxt.lineTo(dddd.time-1431048250,dddd.memory/10000);
cxt.stroke();
},
error:function(){
alert("F");
return false;
}
});
var t1=setTimeout(ss,1000);
}
});
</script>
</head>
<body>
<canvas id="myCanvas" width="800" height="100" style="border:1px solid #c3c3c3;">
Your browser does not support the canvas element.
</canvas>
</body>
</html>
posted on 2015-05-08 09:29 liuwenbohhh 阅读(214) 评论(0) 编辑 收藏 举报
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步