File tree 3 files changed +49
-1
lines changed
3 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,10 @@ gcc -o /tmp/test test.c
14
14
gcc test.cpp -o /tmp/test
15
15
/tmp/test
16
16
17
+ # Objective-C
18
+ gcc test.m -o /tmp/testObjective-C -framework Foundation -framework QuartzCore
19
+ /tmp/testObjective-C
20
+
17
21
# Java
18
22
javac -d /tmp/ Test.java
19
23
java -cp " /tmp/" Test
Original file line number Diff line number Diff line change
1
+ //
2
+ // test.m
3
+ // Test
4
+ //
5
+ // Created by Prang, Andreas on 09.12.15.
6
+ // Copyright © 2015 iSolute-Berlin. All rights reserved.
7
+ //
8
+
9
+ #import < Foundation/Foundation.h>
10
+ #import < QuartzCore/QuartzCore.h>
11
+
12
+ #if __has_feature(objc_arc)
13
+ #define DLog (format, ...) CFShow((__bridge CFStringRef )[NSString stringWithFormat: format, ## __VA_ARGS__]);
14
+ #else
15
+ #define DLog (format, ...) CFShow([NSString stringWithFormat: format, ## __VA_ARGS__]);
16
+ #endif
17
+
18
+ @interface Test :NSObject
19
+ - (long )forEachLoopMaxInteger : (long )max ;
20
+ @end
21
+
22
+ @implementation Test
23
+ - (long )forEachLoopMaxInteger : (long )max {
24
+ long sum = 0 ;
25
+ for (long n = max; n > 0 ; n--) {
26
+ double foo = n / 17 ;
27
+ sum = sum + n ;
28
+ }
29
+ return max;
30
+ }
31
+ @end
32
+
33
+ int main (int argc, const char * argv[]) {
34
+ @autoreleasepool {
35
+
36
+ Test *test = [[Test alloc ]init];
37
+ CFTimeInterval startTime = CACurrentMediaTime ();
38
+ [test forEachLoopMaxInteger: 100000000 ];
39
+ CFTimeInterval elapsedTime = CACurrentMediaTime () - startTime;
40
+
41
+ DLog (@" Objective-C: %.0f " , elapsedTime * 1000 );
42
+ }
43
+ return 0 ;
44
+ }
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ func forEachLoopMaxInteger(max: Int64) -> Int64 {
8
8
var sum : Int64 = 0
9
9
for ( var n = max; n > 0 ; n-- ) {
10
10
let _ = n / 17
11
- sum = sum + n
11
+ sum = sum + n
12
12
}
13
13
return max;
14
14
}
You can’t perform that action at this time.
0 commit comments