Skip to content

Instantly share code, notes, and snippets.

@michaeldwan
Created October 10, 2013 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaeldwan/6920745 to your computer and use it in GitHub Desktop.
Save michaeldwan/6920745 to your computer and use it in GitHub Desktop.
Quick and dirty zlib benchmark
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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment