Skip to content

Instantly share code, notes, and snippets.

@Catfish-Man
Created November 6, 2015 02:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Catfish-Man/1deca0ece0b1c3fd26c0 to your computer and use it in GitHub Desktop.
Save Catfish-Man/1deca0ece0b1c3fd26c0 to your computer and use it in GitHub Desktop.
import Foundation
class Test
{
func testing2(var x : Int) -> Int
{
if x % 3 == 0 {
x += 10
}
x++
return x
}
func test()
{
var time = NSDate.timeIntervalSinceReferenceDate();
var x = 0;
for (var i = 0; i < 100000000; i++)
{
x = testing2(x)
}
let time2 = NSDate.timeIntervalSinceReferenceDate() - time
NSLog("%f seconds", time2)
}
}
Test().test()
vs
#import <Foundation/Foundation.h>
@interface Test : NSObject {
}
@end
@implementation Test
- (int)testing2:(int)x
{
if (x % 3 == 0) x += 10;
x++;
return x;
}
- (void)stuff
{
NSTimeInterval time = [NSDate timeIntervalSinceReferenceDate];
int x = 0;
for (int i = 0; i < 100000000; i++)
{
x = [self testing2:time];
}
time = [NSDate timeIntervalSinceReferenceDate] - time;
NSLog(@"%f seconds!", time);
}
@end
int main() {
Test *t = [[Test alloc] init];
[t stuff];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment