-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMemoryAnalytics.cpp
More file actions
50 lines (44 loc) · 2.23 KB
/
MemoryAnalytics.cpp
File metadata and controls
50 lines (44 loc) · 2.23 KB
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
41
42
43
44
45
46
47
48
49
50
#include "MemoryAnalytics.h"
#include <iostream>
#include <vector>
#include "Chessboard.h"
#include "Chessman.h"
#include "Pawn.h"
#include "Bishop.h"
#include "Rook.h"
#include "King.h"
#include "Queen.h"
#include "Knight.h"
#include "MyChessman.h"
using namespace std;
#define MIN_OBJECT_SIZE (2*sizeof(uint8_t*) + sizeof(ObjHeader))
void MemoryAnalytics::print_class_memory()
{
cout << "--- --- expected --- ---" << endl;
cout << "with VTP (+int, once per class NOT instance, Chessman size with virtual):" << endl;
cout << "char symbol + bool white + std:.vector<Position> valid_moves + std::vector<Position> capture_moves + VTP: \n";
cout << "sizeof(char) + sizeof(bool) + sizeof(std::vector<Position>) + sizeof(std::vector<Position>) + sizeof(int) \n";
cout << sizeof(char) + sizeof(bool) + sizeof(std::vector<Position>*) + sizeof(std::vector<Position>*) + sizeof(int) << endl;
cout << "without VTP (Chessman size without virtual):" << endl;
cout << "char symbol + bool white + std:.vector<Position> valid_moves + std::vector<Position> capture_moves: \n";
cout << "sizeof(char) + sizeof(bool) + sizeof(std::vector<Position>) + sizeof(std::vector<Position>) \n";
cout << sizeof(char) + sizeof(bool) + sizeof(std::vector<Position>*) + sizeof(std::vector<Position>*) << endl;
cout << "--- --- sizeof(Class) --- ---" << endl;
cout << "bool:\t\t" << sizeof(bool) << endl;
cout << "int:\t\t" << sizeof(int) << endl;
cout << "vector<Position>*:\t\t" << sizeof(std::vector<Position>*) << endl;
cout << "Chessman:\t" << sizeof(Chessman) << endl;
cout << "Pawn:\t\t" << sizeof(Pawn) << endl;
cout << "King:\t\t" << sizeof(King) << endl;
cout << "Queen:\t\t" << sizeof(Queen) << endl;
cout << "Rook:\t\t" << sizeof(Rook) << endl;
cout << "Bishop:\t\t" << sizeof(Bishop) << endl;
cout << "MyChessman:\t\t" << sizeof(MyChessman) << endl;
cout << "--- --- sizeof(Instance) --- ---" << endl;
cout << "Pawn:\t\t" << sizeof(*(new Pawn(true))) << endl;
cout << "King:\t\t" << sizeof(*(new King(true))) << endl;
cout << "Queen:\t\t" << sizeof(*(new Queen(true))) << endl;
cout << "Rook:\t\t" << sizeof(*(new Rook(true))) << endl;
cout << "Bishop:\t\t" << sizeof(*(new Bishop(true))) << endl;
cout << "MyChessman:\t\t" << sizeof(*(new MyChessman(true))) << endl;
}