mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2024-12-15 17:51:06 +00:00
chore: add a test for HeapSize() function (#3349)
This commit is contained in:
parent
c8a98fd110
commit
eba722b774
1 changed files with 21 additions and 0 deletions
|
@ -10,6 +10,7 @@
|
|||
#include "absl/strings/str_cat.h"
|
||||
#include "base/gtest.h"
|
||||
#include "base/logging.h"
|
||||
#include "core/heap_size.h"
|
||||
#include "facade/facade_test.h"
|
||||
|
||||
using namespace testing;
|
||||
|
@ -209,4 +210,24 @@ TEST_F(RedisParserTest, NestedArray) {
|
|||
ASSERT_THAT(args_[1].GetVec(), ElementsAre("car"));
|
||||
}
|
||||
|
||||
TEST_F(RedisParserTest, UsedMemory) {
|
||||
vector<vector<uint8_t>> blobs;
|
||||
for (size_t i = 0; i < 100; ++i) {
|
||||
blobs.emplace_back(vector<uint8_t>(200));
|
||||
}
|
||||
EXPECT_GT(dfly::HeapSize(blobs), 20000);
|
||||
|
||||
std::vector<std::unique_ptr<RespVec>> stash;
|
||||
RespVec vec;
|
||||
for (unsigned i = 0; i < 10; ++i) {
|
||||
vec.emplace_back(RespExpr::STRING);
|
||||
vec.back().u = RespExpr::Buffer(nullptr, 0);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < 100; i++) {
|
||||
stash.emplace_back(new RespExpr::Vec(vec));
|
||||
}
|
||||
EXPECT_GT(dfly::HeapSize(stash), 30000);
|
||||
}
|
||||
|
||||
} // namespace facade
|
||||
|
|
Loading…
Reference in a new issue