File tree Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 12
12
13
13
#include <unistd.h>
14
14
15
- /// Returns the number of instructions the process has executed since it was
16
- /// launched.
15
+ /// On macOS returns the number of instructions the process has executed since
16
+ /// it was launched, on all other platforms returns 0 .
17
17
uint64_t getInstructionsExecuted ();
Original file line number Diff line number Diff line change 10
10
//
11
11
//===----------------------------------------------------------------------===//
12
12
13
+ #if __APPLE__
14
+ #include <TargetConditionals.h>
15
+ #if TARGET_OS_MAC && !TARGET_OS_IPHONE
16
+ #define TARGET_IS_MACOS 1
17
+ #endif
18
+ #endif
19
+
13
20
#include "InstructionsExecuted.h"
21
+
22
+ #ifdef TARGET_IS_MACOS
14
23
#include <libproc.h>
15
24
#include <sys/resource.h>
16
25
@@ -21,3 +30,8 @@ uint64_t getInstructionsExecuted() {
21
30
}
22
31
return 0 ;
23
32
}
33
+ #else
34
+ uint64_t getInstructionsExecuted () {
35
+ return 0 ;
36
+ }
37
+ #endif
Original file line number Diff line number Diff line change @@ -190,7 +190,11 @@ class PerformanceTest: ParsableCommand {
190
190
let endDate = Date ( )
191
191
192
192
print ( " Time: \( endDate. timeIntervalSince ( start) / Double( self . iterations) * 1000 ) ms " )
193
- print ( " Instructions: \( Double ( endInstructions - startInstructions) / Double( self . iterations) ) " )
193
+ if endInstructions != startInstructions {
194
+ // endInstructions == startInstructions only happens if we are on non-macOS
195
+ // platforms that don't support `getInstructionsExecuted`. Don't display anything.
196
+ print ( " Instructions: \( Double ( endInstructions - startInstructions) / Double( self . iterations) ) " )
197
+ }
194
198
}
195
199
}
196
200
You can’t perform that action at this time.
0 commit comments