[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Reply to: [list | sender only]
Re: CIF-JSON new draft
- Subject: Re: CIF-JSON new draft
- From: Marcin Wojdyr <wojdyr@xxxxxxxxx>
- Date: Mon, 1 May 2017 18:29:33 +0100
- DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;h=mime-version:in-reply-to:references:from:date:message-id:subject:to;bh=xHvBvxKXEqMgBlOWDKXpRBgpOIt15F8WLksLcaMh0Ok=;b=Eci7rKXFYlVVuB0A69St5kNBc9p6jNgXLBKmG3TwatPqpiUpCX5wXXjzXqoJM5N9VrEmocZCpFM469WJcUT8Os//ADp9P3ercQddSs3Ystkfdway1ioG0lJbNlCySWdO9xI/A8ZuCLu39GAFXnaHfP0/ZRcFXEiB9kGb+6nhnuJwHKkbET3raabR7mhKZZnY3LDshbAKGYUVRg4AgdBR2eJypH5a91bb4qqbfAYQtK7KZGYVgWfSAmX6K0HdDiFmAkB54CUisRuh8kxOCinhxJ0irw77Q0Y8iOSU7PkAxxqyIffs6C4jGxyR9M5WDQbI/73sczlR2GgTLuJboYVQzA==
- In-Reply-To: <CACaHzQV8yQFetF-oLv6nhn6VtAjfkYUsNrgwjfCZoDo10Drh=w@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>
I tried it also on Node v4.2.6 var numbers = require('./numbers.json').numbers vs var numbers = require('./strings.json').strings.map(Number) and the timing is similar to Python 3.5. On 1 May 2017 at 18:03, Marcin Wojdyr <wojdyr@gmail.com> wrote:>>>> Since we are targeting this as a low overhead representation, which I>> associate with performance considerations, I am prepared to entertain>> arguments about performance impact. I am not, however, prepared to accept>> unsupported assertions about performance.>> Fair enough, here is a microbenchmark for you. First using Python2.7:>> $ python -m timeit -s 'import json,sys' 'f=open("numbers.json"); numbers => json.load(f)["numbers"]'> 100 loops, best of 3: 10.2 msec per loop> $ python -m timeit -s 'import json,sys' 'f=open("strings.json"); numbers => [float(x) for x in json.load(f)["strings"]]'> 10 loops, best of 3: 58.1 msec per loop>> In this case using strings is 5x slower.>> Now with Python 3.5:>> $ python3 -m timeit -s 'import json,sys' 'f=open("numbers.json"); numbers => json.load(f)["numbers"]'> 100 loops, best of 3: 12.7 msec per loop> $ python3 -m timeit -s 'import json,sys' 'f=open("strings.json"); numbers => [float(x) for x in json.load(f)["strings"]]'> 10 loops, best of 3: 27.4 msec per loop>> The difference is smaller, but still >2x.>> The input files were prepared using this script:>> import json> import random> numbers = [round(random.uniform(-30, 30), 3) for _ in range(100000)]> with open('numbers.json', 'w') as f:> json.dump({'numbers':numbers}, f)> with open('strings.json', 'w') as f:> json.dump({'strings':[str(x) for x in numbers]}, f)>>> $ du -h strings.json numbers.json> 984K strings.json> 788K numbers.json>>> Marcin_______________________________________________cif-developers mailing listcif-developers@iucr.orghttp://mailman.iucr.org/cgi-bin/mailman/listinfo/cif-developers
Reply to: [list | sender only]
- 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)
- 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):