½áºÏcanvas½øÐÐjavascriptÐÔÄܲâÊÔ
ÔÚ¶Ô³ÌÐò½øÐÐÐÔÄܲâÊÔʱÐèÒª¿¼Âǵ½²»Í¬¹æÄ£ÒÔ¼°²»Í¬Ëã·¨µÄЧÂʵIJ»Í¬
ÏÂÃæµÄÍøÒ³ÊÇÒ»¸ö¶ÔÅÅÐòËã·¨µÄÐÔÄܲâÊÔ£¬¹æÄ£¾ÍÊÇÊý×éµÄ³¤¶È£¬¶ø²âÊÔµÄÁ½¸öº¯Êý·Ö±ðÊÇÊÖ¶¯ÊµÏֵĿìËÙÅÅÐòËã·¨ºÍjavascriptÄÚÖõÄÅÅÐòº¯Êý¡£
<!DOCTYPE window PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<title>Performance</title>
<mce:script type="text/javascript"><!--
var $ = function(id) {
return document.getElementById(id);
};
$.extend = function(target, object) {
for (var i in object) {
target[i] = object[i];
}
return target;
};
// --></mce:script>
<mce:script type="text/javascript" src="performance.js" mce_src="performance.js"></mce:script>
<mce:script type="text/javascript"><!--
var a;
function qsort(l, u) {
if (l >= u) {
return undefined;
}
var i = l, j = u - 1, v = a[u], t;
while (1) {
while (a[i] < v) { i += 1; }
while (a[j] > v) { j -= 1; }
if (i >= j) {
break;
}
t = a[i];
a[i] = a[j];
a[j] = t;
i += 1;
j -= 1;
}
t = a[i];
a[i] = v;
a[u] = t;
qsort(l, j);
qsort(i + 1, u);
};
performance({
// resetº¯ÊýÔÚÿ´Î¸Ä±ä¹æÄ£Ê±±»µ÷Ó㬲ÎÊýxÊǹæÄ£
// Éú³ÉÒ»¸ö³¤¶ÈΪxµÄËæ»úÊý×é
reset: function(x) {
a = [];
while (x--) {
a[x] = ~~(Math.random() * x);
}
},
func: [
function quicksort(x) {
qsort(0, x);
},
function nativesort(x) {
a.sort();
}
],
dimensionStart: 1,
dimensionEnd: 1000,
dimensionIncrement: 1,
});
// --></mce:script>
</head>
<body>
<canvas id="canvas" width="1400" height="800"></canvas>
</body>
performance.js°üº¬Ö÷ÒªµÄ½øÐвâÊԵĴúÂë¡£ÔÚ¿ØÖÆÌ¨ÖÐÊäÈëperformance.start()¿ªÊ¼½øÐвâÊÔ£¬¿ÉÒÔ¿´µ½canvasÉÏ´Ó×óµ½ÓÒ³öÏÖºÚÉ«ÓëºìÉ«µÄµã£¬ºÚÉ«´ú±íquicksort£¬¶øºìÉ«´ú±ínativesort
¿ÉÒÔËæÊ±performance.end()ÖÕÖ¹²âÊÔ
ͼÏñÖеĺáÖá±íʾ¹æÄ££¬¶ø×ÝÖá±íʾÔËÐеÄ
Ïà¹ØÎĵµ£º
JavaScript½Å±¾ÓïÑԵĻù±¾¹¹³ÉÊÇÓÉ¿ØÖÆÓï¾ä¡¢º¯Êý¡¢¶ÔÏó¡¢·½·¨¡¢ÊôÐÔµÈ,À´ÊµÏÖ±à³ÌµÄ¡£
Ò»¡¢
³ÌÐò¿ØÖÆÁ÷
¡¡¡¡ÔÚÈκÎÒ»ÖÖÓïÑÔÖУ¬³ÌÐò¿ØÖÆÁ÷ÊDZØÐëµÄ£¬ËüÄÜʹµÃÕû¸ö³ÌÐò¼õС»ìÂÒ£¬Ê¹Ö®Ë³Àû°´ÆäÒ»¶¨µÄ·½Ê½Ö´ÐС£ÏÂÃæÊÇ
JavaScript³£ÓõijÌÐò¿ØÖÆÁ÷½á¹¹¼°Óï¾ä:
£±¡¢ifÌõ¼þÓï¾ä
¡¡»ù±¾
¸ñʽ
if£¨±íÊöʽ£©
Óï¾ä¶Î£±£»
......
¶¨Òå±äÁ¿
var test=10;
ʹÓöÔÏóÊôÐÔ
¿ÉÒÔʹÓà . ²Ù×÷·û»ñµÃÊôÐÔ,Ò²¿ÉÒÔʹÓÃÊý×éϱê»ñµÃ,±ÈÈç
for(var prop in document)
document.write(document[prop]+"<br>");
With ÉùÃ÷¶ÔÏó,Ö®ºóÔÙÓõ½¶ÔÏó¾Í²»±ØÉùÃ÷ÁË
with(document){
write("Hello World<br>±êÌâ: ");
write(title);
}
³£ÓöÔÏó ......
µÚÒ»Ìâ
(function(){
return typeof arguments;
})();
//ÎÊ×Ô¶¯Ö´Ðк¯Êý»á·µ»ØÊ²Ã´Öµ
// ¾ÍÊÇ¿¼Arguments¶ÔÏóµÄtypeof
// ¿´Æ½Ê±ÓÃfirebug¶à²»¶àÁË¡¡
µÚ¶þÌâ
var f = function g(){ return 23; };
typeof g();
//ÎÊ×îºóÒ»ÐеÄÖ´Ðнá¹û
//¸ù¾Ý±ê×¼£¬ÃüÃûº¯Êý±í´ïʽµÄº¯ÊýÃûÖ»¶Ôº¯Êý ......
JavaScript ¿ÉËãÊÇÊÀ½çÉÏ×îÁ÷Ðеıà³ÌÓïÑÔ£¬ËüÔø±» Web ¿ª·¢Éè¼ÆÊ¦ÌùÉÏØ¬ÃεıêÇ©£¬ËäÈ»ÕæÕýµÄجÃÎÆäʵÊÇ DOM
API£¬Õâ¸ö±»´óÁ¿µÄ¿ª·¢ÓëÉè¼ÆÊ¦ËæÊÖÄéÀ´ÔöÇ¿ËûÃÇµÄ Web ǰ¶ËµÄ½Å±¾ÓïÑÔ£¬Èç½ñÔ½À´Ô½±»ÖØÊÓ£¬ËäÔòÈç´Ë£¬JavaScript
ÈÔȻӵÓкܶàÈÃÈ˷ѽâµÄ¶«Î÷¡£
1. ËüÒÔ Java ÃüÃû£¬µ«²¢²»ÊÇ Java
Ëü×î³õ½Ð Mocha£¬ ½Óן ......
ͻȻ¼äÏëÈ¥ÏÂÊ×fire in the holeµÄÁåÉù£¬ÓÚÊÇÓÃsosoÕÒÁËһϣ¬½øÈëÁËÊÖ»úÀÖÔ° £¨http://download.shouji.com.cn/do/wave?html=&inputname=wave&wname=Fire+in+the+hole+&thsubmit=%E6%90%9C%E7%B4%A2£©£¬Ñ¡Ôñfire in the hole£¬µ¯³ö¸ö´°¿Ú£¬ÌáʾÈÃÊäÈëÊÖ»úºÅÂë¡£ÔÎËÀ£¬²»¾ÍÏÂÊ׸èÂ»¹²»ÈÃÖ±½ÓÏ¡£ºÇºÇ£¬·¢ÏÖÍ ......