diff options
author | 2022-08-09 16:35:06 -0700 | |
---|---|---|
committer | 2022-08-09 16:35:06 -0700 | |
commit | 429abc12781aa6b93417ad6de8a69028900ad33d (patch) | |
tree | b3dd00f04f641dc8ffdfce5586879ffcf8a236d1 /test | |
parent | 3dca3baaec4babf1521f57d46feff6d7c69229aa (diff) | |
download | bun-429abc12781aa6b93417ad6de8a69028900ad33d.tar.gz bun-429abc12781aa6b93417ad6de8a69028900ad33d.tar.zst bun-429abc12781aa6b93417ad6de8a69028900ad33d.zip |
[bun:ffi] ~30% perf improvement for wrapped functions
Diffstat (limited to 'test')
-rw-r--r-- | test/bun.js/ffi-test.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/bun.js/ffi-test.c b/test/bun.js/ffi-test.c index cc87d0528..e508b2c11 100644 --- a/test/bun.js/ffi-test.c +++ b/test/bun.js/ffi-test.c @@ -105,6 +105,19 @@ void *ptr_should_point_to_42_as_int32_t() { return ptr; } +static uint8_t buffer_with_deallocator[128]; +static int deallocatorCalled; +void deallocator(void *ptr, void *userData) { deallocatorCalled++; } +void *getDeallocatorCallback() { + deallocatorCalled = 0; + return &deallocator; +} +void *getDeallocatorBuffer() { + deallocatorCalled = 0; + return &buffer_with_deallocator; +} +int getDeallocatorCalledCount() { return deallocatorCalled; } + bool does_pointer_equal_42_as_int32_t(int32_t *ptr); bool does_pointer_equal_42_as_int32_t(int32_t *ptr) { return *ptr == 42; } |