MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / AllocPerformanceTest

Class AllocPerformanceTest

deps/memkind/src/test/alloc_performance_tests.cpp:35–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33extern const char *PMEM_DIR;
34
35class AllocPerformanceTest: public :: testing::Test
36{
37private:
38 AllocatorFactory allocator_factory;
39
40protected:
41 void SetUp()
42 {
43 allocator_factory.initialize_allocator(AllocatorTypes::STANDARD_ALLOCATOR);
44
45 int err = memkind_create_pmem(PMEM_DIR, PMEM_PART_SIZE, &MEMKIND_PMEM_MOCKUP);
46 ASSERT_EQ(0, err);
47 ASSERT_TRUE(nullptr != MEMKIND_PMEM_MOCKUP);
48 }
49
50 void TearDown()
51 {
52 int err = memkind_destroy_kind(MEMKIND_PMEM_MOCKUP);
53 ASSERT_EQ(0, err);
54 }
55
56 float run(unsigned kind, unsigned call, size_t threads_number,
57 size_t alloc_size, unsigned mem_operations_num)
58 {
59 TaskFactory task_factory;
60 std::vector<Thread *> threads;
61 std::vector<Task *> tasks;
62 TypesConf func_calls;
63 TypesConf allocator_types;
64
65 func_calls.enable_type(FunctionCalls::FREE);
66 func_calls.enable_type(call);
67 allocator_types.enable_type(kind);
68
69 TaskConf conf = {
70 mem_operations_num, //number of memory operations
71 {
72 mem_operations_num, //number of memory operations
73 alloc_size, //min. size of single allocation
74 alloc_size //max. size of single allocatioion
75 },
76 func_calls, //enable function calls
77 allocator_types, //enable allocators
78 11, //random seed
79 false, //does not log memory operations and statistics to csv file
80 };
81
82 for (int i=0; i<threads_number; i++) {
83 Task *task = task_factory.create(conf);
84 tasks.push_back(task);
85 threads.push_back(new Thread(task));
86 conf.seed += 1;
87 }
88
89 ThreadsManager threads_manager(threads);
90 threads_manager.start();
91 threads_manager.barrier();
92

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected