forked from sirodcar/commonx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBrainScanUltra.pas
More file actions
173 lines (137 loc) · 4.44 KB
/
BrainScanUltra.pas
File metadata and controls
173 lines (137 loc) · 4.44 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
unit BrainScanUltra;
{$D-}
interface
{$IFDEF LINUX}
type
TChart = TObject;
{$ELSE}
uses VCLTee.Chart, graphics, sysutils;
{$ENDIF}
procedure MemChart(chart1: TChart);
procedure MemBlockChart(chart1: TChart);
implementation
{$IFNDEF NOSUPERMEM}
uses BigBrainUltra;
{$ENDIF}
{$IFNDEF LINUX}
function ColorBlend(cBackGround, cForeGround: Tcolor; alpha: real): TColor;
var
r1,g1,b1,r2,g2,b2: integer;
r,g,b: integer;
begin
r1 := (cbackGround shr 0) and 255;
g1 := (cbackGround shr 8) and 255;
b1 := (cbackGround shr 16) and 255;
r2 := (cForeGround shr 0) and 255;
g2 := (cForeGround shr 8) and 255;
b2 := (cForeGround shr 16) and 255;
r := round(((r2-r1)*alpha)+r1);
g := round(((g2-g1)*alpha)+g1);
b := round(((b2-b1)*alpha)+b1);
result := (b shl 16)+(g shl 8)+r;
end;
function GetChartColor(x,y: integer; isFree: boolean; bEmptying: boolean): TColor;
type
Tcolors = array [0..12] of TColor;
const
colors: Tcolors = ($0000FF, $00FF00,$FF0000, $FF00FF, $FFFF00, $00FFFF, $AAAAAA, $FF7F00, $7FFF00, $00FF7F, $007FFF, $7F00FF, $FF007F);
var
r,g,b: integer;
begin
x := x mod 12;
result := colors[x];
case y of
0: begin
b := (result shr 16) and 255;
g := (result shr 8) and 255;
r := (result shr 0) and 255;
r := r+((255-r) div 2);
g := g+((255-g) div 2);
b := b+((255-b) div 2);
result := (b shl 16)+(g shl 8)+r;
end;
1: begin
end;
2: begin
result := ((((result shr 16) and 255) div 2) shl 16)
or ((((result shr 8) and 255) div 2) shl 8)
or ((((result shr 0) and 255) div 2) shl 0)
end;
3: begin
result := ((((result shr 16) and 255) div 3) shl 16)
or ((((result shr 8) and 255) div 3) shl 8)
or ((((result shr 0) and 255) div 3) shl 0)
end;
end;
if bEmptying then
result := ColorBlend(result, clWhite, 0.65)
else if IsFree then
result := ColorBlend(result, clBlack, 0.65);
end;
{$ENDIF}
procedure MemChart(chart1: TChart);
{$IFNDEF NOSUPERMEM}
var
t: integer;
b: boolean;
b2: boolean;
{$ENDIF}
begin
{$IFNDEF NOSUPERMEM}
{$IFNDEF LINUX}
ManMan.Lock;
// if ManMan.TryLock then
try
Chart1.SeriesList[0].Clear;
for t:= 0 to ManMan.ManagerCount-1 do begin
Chart1.Title.text.text := 'Memory distribution across '+inttostr(ManMan.ManagerCount)+' managers '+' ('+inttostr(ManMan.DeadCount)+' dead managers not shown)';
ManMan.Managers[t].Lock;
// if ManMan.Managers[t].TryLock then
try
b := ManMan.Managers[t].IsFree;
b2 := ManMan.Managers[t].Emptying;
Chart1.SeriesList[0].Add(ManMan.Managers[t].BlockHeaderOverhead,inttostr(TThreadBlockManager(ManMAn.Managers[t]).LastOwnedThreadID)+':Overhead', GetChartColor(t, 0, b, b2));
Chart1.SeriesList[0].Add(ManMan.Managers[t].UsedBytes,inttostr(TThreadBlockManager(ManMAn.Managers[t]).LastOwnedThreadID)+':Used', GetChartColor(t, 1, b, b2));
Chart1.SeriesList[0].Add(ManMan.Managers[t].WasteBytes,inttostr(TThreadBlockManager(ManMAn.Managers[t]).LastOwnedThreadID)+':Waste', GetChartColor(t, 2,b, b2));
Chart1.SeriesList[0].Add(ManMan.Managers[t].FreeBytes,inttostr(TThreadBlockManager(ManMAn.Managers[t]).LastOwnedThreadID)+':Free', GetChartColor(t, 3,b, b2));
// TPieSeries(Chart1.Serieslist[0]).RotationAngle := TPieSeries(Chart1.Serieslist[0]).RotationAngle+1
//ManMan.Managers[t].checkMem;
finally
ManMan.Managers[t].Unlock;
end;
end;
finally
ManMan.Unlock;
end;
{$ENDIF}
{$ENDIF}
end;
procedure MemBlockChart(chart1: TChart);
{$IFNDEF NOSUPERMEM}
var
t: integer;
{$ENDIF}
begin
{$IFNDEF NOSUPERMEM}
Chart1.SeriesList[0].Clear;
ManMan.Lock;
try
for t:= 0 to ManMan.ManagerCount-1 do begin
Chart1.Title.text.text := 'Memory BLOCK distribution across '+inttostr(ManMan.ManagerCount)+' managers '+' ('+inttostr(ManMan.DeadCount)+' dead managers not shown)';
ManMan.Managers[t].Lock;
try
Chart1.SeriesList[0].Add(ManMan.Managers[t].UsedBlockCount,'('+inttostr(t)+')', GetChartColor(t, 1,false,false));
Chart1.SeriesList[0].Add(ManMan.Managers[t].FreeBlockCount,'('+inttostr(t)+')', GetChartColor(t, 1,true,false));
// TPieSeries(Chart1.Serieslist[0]).RotationAngle := TPieSeries(Chart1.Serieslist[0]).RotationAngle+1
//ManMan.Managers[t].checkMem;
finally
ManMan.Managers[t].Unlock;
end;
end;
ManMan.Clean;
finally
ManMan.Unlock;
end;
{$ENDIF}
end;
end.