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函数返回对象