Skip to content

Instantly share code, notes, and snippets.

@andrei512
Created July 16, 2013 14:20
Show Gist options
  • Select an option

  • Save andrei512/6009166 to your computer and use it in GitHub Desktop.

Select an option

Save andrei512/6009166 to your computer and use it in GitHub Desktop.
[APUtils benchmark:^{
for (int i = 0; i < 1000000; ++i) {
self.testing = @(i);
}
} name:@"self.testing = @(i);"];
[APUtils benchmark:^{
for (int i = 0; i < 1000000; ++i) {
[self setValue:@(i) forKey:@"testing"];
}
} name:@"[self setValue:@(i) forKey:@\"testing\"];"];
[APUtils benchmark:^{
for (int i = 0; i < 1000000; ++i) {
[self performSelector:@selector(setTesting:) withObject:@(i)];
}
} name:@"[self performSelector:@selector(setTesting:) withObject:@(i)];"];
[APUtils benchmark:^{
for (int i = 0; i < 1000000; ++i) {
[self performSelector:NSSelectorFromString(@"setTesting:") withObject:@(i)];
}
} name:@"[self performSelector:NSSelectorFromString(@\"setTesting:\") withObject:@(i)];"];
[APUtils benchmark:^{
SEL selector = NSSelectorFromString(@"setTesting:");
for (int i = 0; i < 1000000; ++i) {
[self performSelector:selector withObject:@(i)];
}
} name:@"[self performSelector:selector withObject:@(i)];"];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment