Lolly 1.4.27
Loading...
Searching...
No Matches
Classes | Macros | Functions
fast_alloc_test.cpp File Reference
#include "a_lolly_test.hpp"
#include "fast_alloc.hpp"
#include "tm_timer.hpp"
Include dependency graph for fast_alloc_test.cpp:

Go to the source code of this file.

Classes

struct  Complex
 

Macros

#define NUM   10000
 

Functions

 TEST_CASE ("test for memory leaks")
 
TEST_MEMORY_LEAK_INIT TEST_CASE ("test basic data types")
 
 TEST_CASE ("test class")
 
 TEST_CASE ("test tm_*_array")
 
 TEST_CASE ("test large bunch of tm_*")
 
TEST_MEMORY_LEAK_ALL TEST_MEMORY_LEAK_RESET TEST_CASE ("test large bunch of tm_*_array with class")
 

Macro Definition Documentation

◆ NUM

#define NUM   10000

Function Documentation

◆ TEST_CASE() [1/6]

TEST_CASE ( "test for memory leaks" )

Definition at line 13 of file fast_alloc_test.cpp.

13 {
14 char* p_char= tm_new<char> ('a');
15 CHECK (*p_char == 'a');
16
17 p_char= tm_new<char> ('b');
18 CHECK (*p_char == 'b');
19
20 *p_char= 'c';
21 CHECK (*p_char == 'c');
22
24
25 char* q_char= tm_new<char> ('z'); // here p_char is modified to 'z'
26
27 // *p_char= 'c'; // behavior of this code is unspecified, DO NOT DO THIS!
28}
The list class represents a linked list.
Definition list.hpp:48
void tm_delete(C *ptr)

◆ TEST_CASE() [2/6]

TEST_MEMORY_LEAK_INIT TEST_CASE ( "test basic data types" )

Definition at line 32 of file fast_alloc_test.cpp.

32 {
33
34 char* ch;
35 int* in;
36 long* lo;
37 double* dou;
38
39 ch = tm_new<char> ();
40 in = tm_new<int> ();
41 lo = tm_new<long> ();
43
44 tm_delete (ch);
45 tm_delete (in);
46 tm_delete (lo);
47 tm_delete (dou);
48}

◆ TEST_CASE() [3/6]

TEST_CASE ( "test class" )

Definition at line 50 of file fast_alloc_test.cpp.

◆ TEST_CASE() [4/6]

TEST_CASE ( "test tm_*_array" )

Definition at line 55 of file fast_alloc_test.cpp.

55 {
58#ifdef OS_WASM
59 const size_t size_prim= 200, size_complex= 100;
60#else
61 const size_t size_prim= 20000000, size_complex= 5000000;
62#endif
67}
void tm_delete_array(C *Ptr)

◆ TEST_CASE() [5/6]

TEST_CASE ( "test large bunch of tm_*" )

Definition at line 70 of file fast_alloc_test.cpp.

70 {
71 const int bnum= 100000;
72 int* volume[bnum];
73 for (int i= 0; i < bnum; i++) {
74 volume[i]= tm_new<int> (35);
75 }
76 for (int i= 0; i < bnum; i++) {
77 tm_delete (volume[i]);
78 }
79}

◆ TEST_CASE() [6/6]

Definition at line 84 of file fast_alloc_test.cpp.

84 {
85
86#ifdef OS_WASM
87#define NUM 100
88#else
89#define NUM 10000
90#endif
92 for (int i= 0; i < NUM; i++) {
94 }
95 for (int i= 0; i < NUM; i++) {
97 }
98}
#define NUM