blob: 2d1d4129495de5a75db1ba6271a37e7e94a2acbe (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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;
}
|