Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

普遍认为效率不错的JSONKit,与苹果官方的JSONSerialization究竟差距有多大????

License

Notifications You must be signed in to change notification settings

lsqiang/JSONKit-NSJSONSerialization-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

3 Commits

Repository files navigation

JSONKit-NSJSONSerialization-

普遍认为效率不错的JSONKit,与苹果官方的JSONSerialization究竟差距有多大???? ##JSONKit enter image description here

##NSSerialization enter image description here

##效率比较代码(执行100*1000次查看内存消耗)

  • (void)loadJSONKit {

    NSString *path = [[NSBundle mainBundle] pathForResource:@"videos.json" ofType:nil];

    NSURL *url = [NSURL fileURLWithPath:path];

    NSURLRequest *request = [NSURLRequest requestWithURL:url];

    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue]completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {

     CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
     for (int i=0; i<100*1000; i++) {
     [[JSONDecoder decoder] objectWithData:data];
     }
     NSLog(@"JSONKit耗时=====>%f", CFAbsoluteTimeGetCurrent() - start);
    

    }]; }

  • (void)loadJSONSerialization {

    NSString *path = [[NSBundle mainBundle] pathForResource:@"videos.json" ofType:nil];

    NSURL *url = [NSURL fileURLWithPath:path];

    NSURLRequest *request = [NSURLRequest requestWithURL:url];

    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue]completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {

     CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
     for (int i=0; i<100*1000; i++) {
     [NSJSONSerialization JSONObjectWithData:data options:0 error:NULL];
     }
     NSLog(@"NSJSONSerialization耗时=====>%f", CFAbsoluteTimeGetCurrent() - start);
    

    }]; }

About

普遍认为效率不错的JSONKit,与苹果官方的JSONSerialization究竟差距有多大????

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

AltStyle によって変換されたページ (->オリジナル) /