diff options
| author | vvvv <[email protected]> | 2024-11-07 04:19:26 +0300 |
|---|---|---|
| committer | vvvv <[email protected]> | 2024-11-07 04:29:50 +0300 |
| commit | 2661be00f3bc47590fda9218bf0386d6355c8c88 (patch) | |
| tree | 3d316c07519191283d31c5f537efc6aabb42a2f0 /yql/essentials/minikql/perf/alloc/alloc.cpp | |
| parent | cf2a23963ac10add28c50cc114fbf48953eca5aa (diff) | |
Moved yql/minikql YQL-19206
init
[nodiff:caesar]
commit_hash:d1182ef7d430ccf7e4d37ed933c7126d7bd5d6e4
Diffstat (limited to 'yql/essentials/minikql/perf/alloc/alloc.cpp')
| -rw-r--r-- | yql/essentials/minikql/perf/alloc/alloc.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/yql/essentials/minikql/perf/alloc/alloc.cpp b/yql/essentials/minikql/perf/alloc/alloc.cpp new file mode 100644 index 00000000000..2d1d4129495 --- /dev/null +++ b/yql/essentials/minikql/perf/alloc/alloc.cpp @@ -0,0 +1,40 @@ +#include <util/datetime/cputimer.h> +#include <yql/essentials/public/udf/udf_allocator.h> +#include <yql/essentials/minikql/mkql_alloc.h> + +using namespace NKikimr; +using namespace NKikimr::NMiniKQL; +using namespace NKikimr::NUdf; + +namespace { + inline void MyFree(const void* p, size_t) { return free(const_cast<void*>(p)); } + + template <void*(*Alloc)(ui64), void (*Free)(const void*,ui64)> + void Test(const TString& name) { + TSimpleTimer timer; + for (ui32 i = 0; i < 100000000; ++i) { + std::array<void*, 10> strs; + for (ui32 j = 0; j < strs.size(); ++j) { + void* p = Alloc(32); + *((volatile char*)p) = 0xff; + strs[j] = p; + } + + for (ui32 j = 0; j < strs.size(); ++j) { + void* p = strs[j]; + Free(p, 32); + } + } + + Cerr << "[" << name << "] Elapsed: " << timer.Get() << "\n"; + } +} + +int main(int, char**) { + Test<&malloc, &MyFree>("malloc"); + { + TScopedAlloc sopedAlloc(__LOCATION__); + Test<&UdfAllocateWithSize, &UdfFreeWithSize>("mkql"); + } + return 0; +} |
