-
Notifications
You must be signed in to change notification settings - Fork 617
Json11 Benchmarks #41
Comments
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. |
@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 - (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
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 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#### |
First I want to thank you @dropbox to share this project.
I'm handling this simple json benchmark project https://github.com/loretoparisi/ios-json-benchmark
Here some results compared to well known parsers (C++, Objective-C so far only) for mobile devices and not like
JSONKit
,Gason
,RapidJSON
, Apple'sNSJSONSerialization
(more to come). I have integratedJson11
The integration is as simple as
where
[NSString stringWithstring:jsonString]
converts astd:string
to a iOS FoundationNSString
5 times parsing of a 322 Bytes JSON file
1 times parsing of a 55435 Bytes JSON file
100 times parsing of a 55435 Bytes JSON file
The text was updated successfully, but these errors were encountered: