Mercurial > op > Looping
view Looping.xhtml @ 10:308cc64c24b9 >>178
Goのソースコードを追加。
author | "uncorrelated zombie" <uncorrelated@yahoo.co.jp> |
---|---|
date | Thu, 24 Feb 2011 07:31:17 +0900 |
parents | 30b521e712f5 |
children |
line wrap: on
line source
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html 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" xml:lang="ja" lang="ja"> <head> <title>Looping</title> <script type="text/javascript"><![CDATA[ var Looping = function(){ this.n0 = 0; this.calc = function(n){ var n1 = this.n0 + (1 - 2*(n%2)); this.n0 = n; return n1; }; }; function benchmark(){ document.forms[0].elements["text1"].value = ""; document.forms[0].elements["text2"].value = ""; var o = new Looping(); var n = 1; var st = new Date(); for(var c=0;c<2147483647;c++){ n = o.calc(n); } var et = new Date(); document.forms[0].elements["text1"].value = n; document.forms[0].elements["text2"].value = (et - st)/1000; } ]]></script> <style type="text/css"> input { width: 100%; } </style> </head> <body> <form> <div style="width:320px;"> <div style="margin:4px;"> 計算結果 <input type="text" name="text1" value="" /> </div> <div style="margin:4px;"> 経過時間 <input type="text" name="text2" value="" /> </div> <div style="margin:4px;"> <input type="button" value="実行" onclick="benchmark();" /> </div> </div> </form> </body> </html>