Skip to content

Instantly share code, notes, and snippets.

@michaeldwan
Created October 10, 2013 15:54
Show Gist options
  • Save michaeldwan/6920745 to your computer and use it in GitHub Desktop.
Save michaeldwan/6920745 to your computer and use it in GitHub Desktop.

Revisions

  1. michaeldwan created this gist Oct 10, 2013.
    25 changes: 25 additions & 0 deletions benchmark.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:entry];

    NSLog(@"%@", data);

    NSLog(@"Uncompressed: %d", [data length]);

    double start;

    start = [NSDate timeIntervalSinceReferenceDate];
    for (int x = 0; x < 50000; x++) {
    [[data zlibDeflate] length];
    }
    NSLog(@"z took %f seconds", [NSDate timeIntervalSinceReferenceDate] - start);


    start = [NSDate timeIntervalSinceReferenceDate];
    for (int x = 0; x < 50000; x++) {
    [[data gzipDeflate] length];
    }
    NSLog(@"gz took %f seconds", [NSDate timeIntervalSinceReferenceDate] - start);

    NSLog(@"zlib Compressed: %d", [[data zlibDeflate] length]);
    NSLog(@"gzip Compressed: %d", [[data gzipDeflate] length]);

    id decoded = [NSKeyedUnarchiver unarchiveObjectWithData:data]