Comments (2)
Cool! I'm really curious about the really high max values for json11 in 2 cases (and for JSONKit in one case). Caching effects of some sort (is it always the first time)? Or some kind of a one-time interruption from outside the system? I can't believe that parsing the same data sometimes legitimately takes 150x more time.
Regardless, this would be a god test case to use for some profiling, if someone felt inclined.
from json11.
@artwyman Yes I agree, infact that sounds quite strange to me! Also I can see a non proportional timing when parsing X times the same JSON, even if this is something that happens to several parsers.
This is the timing code (the snippet here show two parsers) in the file MCTestViewController.m
- (NSNumber *)parseWithJson11:(NSString *)content
{
NSDate *startTime = [NSDate date];
Json11 *rpdj = [Json11 new];
id result=[rpdj parse:content];
float elapsedTime = [startTime timeIntervalSinceNow] * -1000;
if (result == nil)
elapsedTime = -1.0;
return [NSNumber numberWithFloat:elapsedTime];
}
- (NSNumber *)parseWithJsonModernCPlusPlus:(NSString *)content {
NSDate *startTime = [NSDate date];
JsonModernCPlusPlus *rpdj = [JsonModernCPlusPlus new];
id result=[rpdj parse:content];
float elapsedTime = [startTime timeIntervalSinceNow] * -1000;
if (result == nil)
elapsedTime = -1.0;
return [NSNumber numberWithFloat:elapsedTime];
}
where as said above I do
#import "Json11.h"
#import "json11.hpp"
#import "CppStringAdditions.h"
@implementation Json11
- (NSString*)parse:(NSString*)json {
const char* data = [json UTF8String];
json11::Json parser;
parser = json11::Json(data);
std::string jsonString;
parser.dump(jsonString);
//printf("%s", jsonString.c_str());
return [NSString stringWithstring:jsonString];
}
@end
Said that, I'm doing again the tests on
XCode 7.1 / iOS 9.0 / ARM64 / iPhone6
So I have tested for 1, 5 and 100 times parsing a small a 322 Bytes JSON file and a big a 55435 Bytes JSON file and tested json11
, gason
and JSON Forn Modern C++
(now added), that are all JSON C++ parsers.
The biggest file (uncompressed 55435 Bytes) has nested json objects like:
"track_list": [
{
"track": {
"track_id": 72612817,
"track_mbid": "",
"track_isrc": "GBUM71400955",
"track_spotify_id": "",
"track_soundcloud_id": 0,
"track_xboxmusic_id": "",
"track_name": "Bailando (Spanish Version)",
"track_name_translation_list": [],
"track_rating": 91,
"track_length": 243,
"commontrack_id": 39807317,
"instrumental": 0,
"explicit": 0,
"has_lyrics": 1,
"has_subtitles": 1,
"num_favourite": 848,
"lyrics_id": 9615270,
"subtitle_id": 2871021,
"album_id": 19584902,
"album_name": "SEX AND LOVE",
"artist_id": 27082008,
"artist_mbid": "",
"artist_name": "Enrique Iglesias feat. Descemer Bueno & Gente de Zona",
"album_coverart_100x100": "http://static.musixmatch.com/images-storage/albums8/7/0/0/8/5/7/30758007.jpg",
"album_coverart_350x350": "http://static.musixmatch.com/images-storage/albums8/7/0/0/8/5/7/30758007_350_350.jpg",
"album_coverart_500x500": "http://static.musixmatch.com/images-storage/albums8/7/0/0/8/5/7/30758007_500_500.jpg",
"album_coverart_800x800": "http://static.musixmatch.com/images-storage/albums8/7/0/0/8/5/7/30758007_800_800.jpg",
"track_share_url": "https://community.musixmatch.com/lyrics/Enrique-Iglesias-feat-Descemer-Bueno-Gente-de-Zona/Bailando-%28Spanish-Version%29",
"track_edit_url": "https://community.musixmatch.com/lyrics/Enrique-Iglesias-feat-Descemer-Bueno-Gente-de-Zona/Bailando-%28Spanish-Version%29?utm_source=application&utm_campaign=api&utm_medium=musixmatch-iphone",
"commontrack_vanity_id": "Enrique-Iglesias-feat-Descemer-Bueno-Gente-de-Zona/Bailando-(Spanish-Version)",
"updated_time": "2014-05-26T08:55:26Z",
"primary_genres": {
"music_genre_list": [
{
"music_genre": {
"music_genre_id": 14,
"music_genre_parent_id": 34,
"music_genre_name": "Pop",
"music_genre_name_extended": "Pop",
"music_genre_vanity": "Pop"
}
}
]
},
"secondary_genres": {
"music_genre_list": [
{
"music_genre": {
"music_genre_id": 1117,
"music_genre_parent_id": 12,
"music_genre_name": "Pop Latino",
"music_genre_name_extended": "Latin / Pop Latino",
"music_genre_vanity": "Latin-Pop-Latino"
}
}
]
}
}
},
The smallest json file (322 Bytes) has a simple flat structure like:
"location": {
"GEOIP_CITY_COUNTRY_CODE": "IT",
"GEOIP_CITY_COUNTRY_CODE3": "ITA",
"GEOIP_CITY_COUNTRY_NAME": "Italy",
"GEOIP_CITY": "Bologna",
"GEOIP_CITY_CONTINENT_CODE": "EU",
"GEOIP_LATITUDE": 44.4938,
"GEOIP_LONGITUDE": 11.3387
}
####1 times parsing of a 55435 Bytes JSON file####
####5 times parsing of a 55435 Bytes JSON file####
####100 times parsing of a 55435 Bytes JSON file####
####1 time 322 Bytes JSON file####
####5 times 322 Bytes JSON file####
####100 times 322 Bytes JSON file####
from json11.
Related Issues (20)
- is it possible to add fields to the json? HOT 1
- in json11.cpp line 161 , why use static_cast, what if a json object is a runtime parsed object HOT 1
- clang 6.0 compilation error HOT 2
- Check if a json object key exists HOT 2
- differentiate between "number" and "integer" as per json schema HOT 1
- Tag Versioning HOT 6
- Number size issue.
- Can't parse wstring?
- auto casting HOT 4
- has_shape() always returns true when used with json11::Json::NUL HOT 1
- [Feature] conan package manager support HOT 1
- Order serealization Json::object HOT 2
- ASAN reports runtime error HOT 1
- swig4.0.0 and mingw compile the test.cpp(main modified to be a function) :error: 'final' is not a member of 'json11' HOT 3
- can't be loaded as a dll in low version c++? HOT 2
- Warning '-Werror=overloaded-virtual' with gcc-5.1.0 --std=c++14 HOT 1
- Making object_items(), array_items() not const or alternatively support mutable_object_items() HOT 1
- Super stuff. HOT 1
- No API to add Json (f.e. array) to Json::object outside of ctor. HOT 1
- Buliding for windows? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from json11.