[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bob
Reply to: [list | sender only]
Re: CIF-JSON new draft
- Subject: Re: CIF-JSON new draft
- From: Robert Hanson <hansonr@xxxxxxxxxx>
- Date: Mon, 1 May 2017 15:09:21 -0500
- DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stolaf.edu; s=stolaf;h=mime-version:in-reply-to:references:from:date:message-id:subject:to;bh=R2bdCkGWH/02mgeuHKi7y2AM8h1rfnU2r3clUnyIGFg=;b=rB1eylpnioQCRsHHMFeNKM2Q9SwNtazf9THt+PnVnFo7kS7w0Yb2mybSM835A7M9i7Z3tuIifmtjtLzljtxgCcFB9ca0SrkwAGcBbdkw70dY9Pvudm/IT5mzjApMTvBROdds6Vy1QqG6Dox3fyh9uQ0KYRHOdTGhdP6ROGyHqLg=
- In-Reply-To: <CACaHzQXZLL77jBMdKhfJHXg8JkxUkwH29MGKyGsYfdfK_2BABA@mail.gmail.com>
- References: <CAM+dB2ey9kKLoZY=WE7Uy-fiWTGhQaFx7fcgODcYfhrNPwXkQw@mail.gmail.com><CACaHzQU-NPvorqZzARhnsTLaAU_tqpp9v56fJss9C9NG--ps0A@mail.gmail.com><MWHPR04MB051226521AF5A8F60AA4BC67E0140@MWHPR04MB0512.namprd04.prod.outlook.com><CACaHzQV8yQFetF-oLv6nhn6VtAjfkYUsNrgwjfCZoDo10Drh=w@mail.gmail.com><CAF_YUvUEOaCiPpoZ8d96HpxScgiJsGBQAO2RA7jVMFBUmWEU_w@mail.gmail.com><CACaHzQXZLL77jBMdKhfJHXg8JkxUkwH29MGKyGsYfdfK_2BABA@mail.gmail.com>
Marcin,
Right, OK. Here it is with a 1,000,000 element array of random strings or numbers.
Does this code look better? Each includes JSON parsing of the array, which either has strings or numbers. The first also requires, then, parsing of the floats upon use.
var c = 0
a = "[0"
for (var i = 0; i < 1000000; i++)
a += ',"' + Math.random() + '"';
a += "]"
x = "[0"
for (var i = 0; i < 1000000; i++)
x+= "," + Math.random();
x += "]"
for (j = 1; j < 5; j++) {
t = +new Date;
b = JSON.parse(a);
for (var i = 0; i < 1000000; i++) {
c = parseFloat(b[i]);
}
t = +new Date - t;
document.write(t + " ms parseFloat(JSON.parse([str,str,str...]))<br>");
}
document.write("<br>")
for (j = 1; j < 5; j++) {
t = +new Date;
d = JSON.parse(x);
for (var i = 0; i < 1000000; i++) {
c = d[i];
}
t = +new Date - t;
document.write(t + " ms JSON.parse([num,num,num,num])<br>");
}
652 ms parseFloat(JSON.parse([str,str,str...]))
621 ms parseFloat(JSON.parse([str,str,str...]))
620 ms parseFloat(JSON.parse([str,str,str...]))
618 ms parseFloat(JSON.parse([str,str,str...]))
601 ms JSON.parse([num,num,num,num])
570 ms JSON.parse([num,num,num,num])
578 ms JSON.parse([num,num,num,num])
569 ms JSON.parse([num,num,num,num])
In my mind this is not a significant difference.
Right, OK. Here it is with a 1,000,000 element array of random strings or numbers.
Does this code look better? Each includes JSON parsing of the array, which either has strings or numbers. The first also requires, then, parsing of the floats upon use.
var c = 0
a = "[0"
for (var i = 0; i < 1000000; i++)
a += ',"' + Math.random() + '"';
a += "]"
x = "[0"
for (var i = 0; i < 1000000; i++)
x+= "," + Math.random();
x += "]"
for (j = 1; j < 5; j++) {
t = +new Date;
b = JSON.parse(a);
for (var i = 0; i < 1000000; i++) {
c = parseFloat(b[i]);
}
t = +new Date - t;
document.write(t + " ms parseFloat(JSON.parse([str,str,str...]))<br>");
}
document.write("<br>")
for (j = 1; j < 5; j++) {
t = +new Date;
d = JSON.parse(x);
for (var i = 0; i < 1000000; i++) {
c = d[i];
}
t = +new Date - t;
document.write(t + " ms JSON.parse([num,num,num,num])<br>");
}
652 ms parseFloat(JSON.parse([str,str,str...]))
621 ms parseFloat(JSON.parse([str,str,str...]))
620 ms parseFloat(JSON.parse([str,str,str...]))
618 ms parseFloat(JSON.parse([str,str,str...]))
601 ms JSON.parse([num,num,num,num])
570 ms JSON.parse([num,num,num,num])
578 ms JSON.parse([num,num,num,num])
569 ms JSON.parse([num,num,num,num])
In my mind this is not a significant difference.
_______________________________________________ cif-developers mailing list cif-developers@iucr.org http://mailman.iucr.org/cgi-bin/mailman/listinfo/cif-developers
Reply to: [list | sender only]
- Follow-Ups:
- Re: CIF-JSON new draft (James Hester)
- Re: CIF-JSON new draft (Robert Hanson)
- References:
- CIF-JSON new draft (James Hester)
- Re: CIF-JSON new draft (Marcin Wojdyr)
- RE: CIF-JSON new draft (Bollinger, John C)
- Re: CIF-JSON new draft (Marcin Wojdyr)
- Re: CIF-JSON new draft (Robert Hanson)
- Re: CIF-JSON new draft (Marcin Wojdyr)
- Prev by Date: Re: CIF-JSON new draft
- Next by Date: Re: CIF-JSON new draft
- Prev by thread: Re: CIF-JSON new draft
- Next by thread: Re: CIF-JSON new draft
- Index(es):