-
Notifications
You must be signed in to change notification settings - Fork 12
147 lines (135 loc) · 2.99 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
@program cmd-@sizer
1 99999 d
1 i
$include $lib/match
$def locknodebytes 18
$def propdirbytes 28
$def propbytes 28
$def objbytes 96
lvar bytesused
lvar overhead
lvar propcount
: init ( -- )
0 bytesused !
0 overhead !
0 propcount !
;
: inc_bytes ( i -- )
bytesused @ + bytesused !
;
: inc_overhead ( -- )
overhead @ 12 + overhead !
;
: props_sizer_rec (d s -- )
over swap "/" strcat nextprop
dup not if pop pop exit then
inc_overhead
propdirbytes inc_bytes
begin
dup while
propcount @ 1 + propcount !
inc_overhead
propdirbytes inc_bytes
inc_overhead
dup strlen 1 + inc_bytes
over over getpropstr
dup if
strlen 1 + inc_bytes
inc_overhead
else pop
then
over over propdir? if
over over props_sizer_rec
then
over swap nextprop
repeat
pop pop
;
: props_sizer (d -- )
"" props_sizer_rec
;
: lock_sizer_rec ({s} -- )
dup begin
dup while
dup locknodebytes * inc_bytes
inc_overhead
2 /
repeat pop
begin
dup while 1 -
swap pop
repeat pop
;
: lock_sizer (d -- )
dup getlockstr "#" explode
lock_sizer_rec
getlockstr ":" explode
lock_sizer_rec
;
: obj_sizer (d -- )
objbytes inc_bytes
dup name strlen 1 + inc_bytes
inc_overhead
dup props_sizer
lock_sizer
;
: display_size (d -- )
unparseobj
" takes up an estimated " strcat
bytesused @ overhead @ + intostr strcat
" bytes of memory." strcat tell
;
lvar who
lvar totalbytes
: main
"me" match me !
#-1 who !
0 totalbytes !
command @ "@sizeall" stringcmp not
command @ "@sizeallq" stringcmp not or if
pmatch dup not if
pop "I don't know who you mean." tell
exit
then
me @ over dbcmp not
me @ "wizard" flag? not and if
pop "Permission denied." tell
exit
then
"This will take some time to finish, so I'll tell you when I'm done."
tell who !
0 begin
dup dbtop int < while
dup dbref ok? if
dup dbref owner who @ dbcmp if
init dup dbref obj_sizer
command @ "@sizeallq" stringcmp if
dup dbref display_size
then
bytesused @ overhead @ +
totalbytes @ + totalbytes !
1 sleep
then
then
1 +
repeat pop
totalbytes @ intostr
" estimated bytes uses total." strcat
"@sizeall complete." tell
tell
else
match_controlled
dup not if pop exit then
init dup obj_sizer
display_size
then
;
.
c
q
@register #me cmd-@sizer=tmp/prog1
@set $tmp/prog1=V
@set $tmp/prog1=W
@action @sizer;@sizeall;@sizeallq;@size;@siz;@si=#0=tmp/exit1
@link $tmp/exit1=$tmp/prog1
@register #me =tmp