sub main
Dim testobj,t,i,v
t=timer()
for i=0 to 49999
set testobj = getjson()
next
response.write "建立50000次JSON對象花費"&(timer()-t)&"s<br/>"
t=timer()
for i=0 to 49999
testobj.set "str"&i,i
next
response.write "寫入50000次JSON對象花費"&(timer()-t)&"s<br/>"
t=timer()
for i=0 to 49999
v = testobj.get("str"&i)
next
response.write "讀取50000次JSON對象花費"&(timer()-t)&"s<br/>"
end sub
main
<script language="javascript" runat="server">
function json() {
if(arguments.length > 0 )
this.obj=eval(arguments[0]);
else
this.obj={};
}
json.prototype={
set:function(key,value){
this.obj[key]=value;
},
get:function(key){
return this.obj[key];
},
del:function(key){
delete this.obj[key];
},
load:function(str){
this.obj=Application[str];
},
save:function(str){
Application[str]=this.obj;
}
}
function getjson() {
return new json();
}
</script>
隻能vbs調用js函數傳回對象