mirek / corejson Goto Github PK
View Code? Open in Web Editor NEWCore Foundation, libyajl based JSON support.
Core Foundation, libyajl based JSON support.
Unable to reproduce claimed performance numbers. Timing based on the twitter_public_timeline.json
file in Sams json-benchmarks, using (approximately) gcc-4.2 -arch x86_64 -DNS_BLOCK_ASSERTIONS -Os
:
JSONKit | decode: min: 415.000 us, avg: 424.730 us, char/s: 57775527.98, decodes: 1000 json-framework | decode: min: 1675.000 us, avg: 1687.973 us, char/s: 14537554.81, decodes: 1000 CoreJSON | decode: min: 1230.000 us, avg: 2641.324 us, char/s: 9290416.47, decodes: 1000
It's not clear to me how CoreJSON can significantly improve on the times turned in by YAJL-objc. After parsing overhead is accounted for (which libyajl
handles), the next major contributor to overall parsing time is in object instantiation, which is fairly considerable. This primarily how JSONKit is able to turn in better times than the other major libraries- it has a recently instantiated object cache to significantly reduce this overhead.
Using
NSError *error = NULL;
NSString *json = [NSString stringWithContentsOfFile:@"example.json" encoding:NSUTF8StringEncoding error:&error];
CoreJSONRef jsonRef = JSONCreateWithString(NULL, (CFStringRef)json);
CFTypeRef jsonObjectRef = JSONGetObject(jsonRef);
[(id)jsonObjectRef autorelease];
JSONRelease(jsonRef);
... leaks memory like a sieve!
shell% leaks -nocontext 20732 | more leaks Report Version: 2.0 Process: bench [20732] Path: /Users/johne/projects/json/CoreJSON/build/Debug/bench Load Address: 0x100000000 Identifier: bench Version: ??? (???) Code Type: X86-64 (Native) Parent Process: tcsh [504] Date/Time: 2011-02-17 12:59:23.723 -0500 OS Version: Mac OS X 10.6.6 (10J567) Report Version: 6 Process 20732: 2158 nodes malloced for 383 KB Process 20732: 114 leaks for 80864 total leaked bytes. Leak: 0x100841800 size=1024 zone: DefaultMallocZone_0x100013000 Call stack: [thread 0x7fff700c3ca0]: | 0x2 | start | main | JSONCreateWithString | JSONParseWithString | yajl_do_parse | __JSONParserAppen dMapStart | __JSONStackEntryCreate | malloc_zone_malloc Leak: 0x100841c00 size=1024 zone: DefaultMallocZone_0x100013000 Call stack: [thread 0x7fff700c3ca0]: | 0x2 | start | main | JSONCreateWithString | JSONParseWithString | yajl_do_parse | __JSONParserAppen dMapStart | __JSONStackEntryCreate | malloc_zone_malloc Leak: 0x100842000 size=1024 zone: DefaultMallocZone_0x100013000 Call stack: [thread 0x7fff700c3ca0]: | 0x2 | start | main | JSONCreateWithString | JSONParseWithString | yajl_do_parse | __JSONParserAppen dMapStart | __JSONStackEntryCreate | malloc_zone_malloc ... [snip] ...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.