-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c1a893
commit a3efc57
Showing
5 changed files
with
56 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
find_package(benchmark REQUIRED) | ||
|
||
add_executable(benchmark_objc_msgSend objc_msgSend.cpp TestClass.m) | ||
|
||
target_compile_options(benchmark_objc_msgSend PRIVATE "-fobjc-runtime=gnustep-2.0") | ||
target_link_libraries(benchmark_objc_msgSend benchmark::benchmark objc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@interface TestClass | ||
- (int)answer; | ||
@end | ||
|
||
@implementation TestClass | ||
- (int)answer | ||
{ | ||
return 42; | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <benchmark/benchmark.h> | ||
#include "../objc/runtime.h" | ||
#include <assert.h> | ||
|
||
static id testClass; | ||
static SEL answerSel; | ||
|
||
static void objc_msgSendSetup(const benchmark::State& state) { | ||
testClass = objc_getClass("TestClass"); | ||
answerSel = sel_registerName("answer"); | ||
} | ||
|
||
static void objc_msgSend(benchmark::State& state) { | ||
for (auto _ : state) | ||
{ | ||
id a = objc_msgSend(testClass, answerSel); | ||
assert((uintptr_t)a == 42); | ||
} | ||
} | ||
// Register the function as a benchmark | ||
BENCHMARK(objc_msgSend)->Setup(objc_msgSendSetup)->Repetitions(25); | ||
|
||
BENCHMARK_MAIN(); |