Database System 0.1.0
Advanced C++20 Database System with Multi-Backend Support
Loading...
Searching...
No Matches
MemoryStressTest Class Reference

Test fixture for memory stress tests. More...

Inheritance diagram for MemoryStressTest:
Inheritance graph
Collaboration diagram for MemoryStressTest:
Collaboration graph

Protected Member Functions

void SetUp () override
 
void TearDown () override
 
size_t getCurrentMemoryUsage ()
 Get current memory usage in bytes (platform-specific)
 
std::string formatBytes (size_t bytes)
 Convert bytes to human-readable format.
 

Protected Attributes

std::unique_ptr< sqlite_backenddb_
 

Detailed Description

Test fixture for memory stress tests.

Definition at line 38 of file memory_stress_test.cpp.

Member Function Documentation

◆ formatBytes()

std::string MemoryStressTest::formatBytes ( size_t bytes)
inlineprotected

Convert bytes to human-readable format.

Definition at line 78 of file memory_stress_test.cpp.

78 {
79 if (bytes > 1024 * 1024) {
80 return std::to_string(bytes / (1024 * 1024)) + " MB";
81 } else if (bytes > 1024) {
82 return std::to_string(bytes / 1024) + " KB";
83 }
84 return std::to_string(bytes) + " B";
85 }

◆ getCurrentMemoryUsage()

size_t MemoryStressTest::getCurrentMemoryUsage ( )
inlineprotected

Get current memory usage in bytes (platform-specific)

Definition at line 62 of file memory_stress_test.cpp.

62 {
63#ifdef __APPLE__
64 struct mach_task_basic_info info;
65 mach_msg_type_number_t count = MACH_TASK_BASIC_INFO_COUNT;
66 if (task_info(mach_task_self(), MACH_TASK_BASIC_INFO,
67 (task_info_t)&info, &count) == KERN_SUCCESS) {
68 return info.resident_size;
69 }
70#endif
71 // Return 0 for unsupported platforms
72 return 0;
73 }
@ info
Informational messages (default)

◆ SetUp()

void MemoryStressTest::SetUp ( )
inlineoverrideprotected

Definition at line 42 of file memory_stress_test.cpp.

42 {
43 db_ = std::make_unique<sqlite_backend>();
44#ifdef USE_SQLITE
45 connection_config config;
46 config.database = ":memory:";
47 ASSERT_TRUE(db_->initialize(config).is_ok());
48#else
49 GTEST_SKIP() << "SQLite not available";
50#endif
51 }
std::unique_ptr< sqlite_backend > db_
Configuration for database connection.
#define ASSERT_TRUE(condition, message)

References ASSERT_TRUE, database::core::connection_config::database, and db_.

◆ TearDown()

void MemoryStressTest::TearDown ( )
inlineoverrideprotected

Definition at line 53 of file memory_stress_test.cpp.

53 {
54 if (db_ && db_->is_initialized()) {
55 db_->shutdown();
56 }
57 }

References db_.

Member Data Documentation

◆ db_

std::unique_ptr<sqlite_backend> MemoryStressTest::db_
protected

Definition at line 40 of file memory_stress_test.cpp.

Referenced by SetUp(), and TearDown().


The documentation for this class was generated from the following file: