@@ -27,6 +27,19 @@ function formatExecutionTime(time) {
27
27
return `${ ( time / 1000.0 ) . toFixed ( 2 ) } s`
28
28
}
29
29
30
+ // Reference: https://gist.github.com/zentala/1e6f72438796d74531803cc3833c039c
31
+ function formatBytes ( bytes , decimals ) {
32
+ if ( bytes === 0 ) {
33
+ return '0 B'
34
+ }
35
+ const k = 1024 ,
36
+ dm = decimals || 2 ,
37
+ sizes = [ 'Bytes' , 'KB' , 'MB' , 'GB' , 'TB' , 'PB' , 'EB' , 'ZB' , 'YB' ] ,
38
+ i = Math . floor ( Math . log ( bytes ) / Math . log ( k ) ) ;
39
+ return parseFloat ( ( bytes / Math . pow ( k , i ) ) . toFixed ( dm ) ) + ' ' + sizes [ i ] ;
40
+ }
41
+
42
+
30
43
// Reference: https://github.com/ltdrdata/ComfyUI-Manager/blob/main/js/comfyui-manager.js
31
44
function drawBadge ( node , orig , restArgs ) {
32
45
let ctx = restArgs [ 0 ] ;
@@ -35,7 +48,7 @@ function drawBadge(node, orig, restArgs) {
35
48
if ( ! node . flags . collapsed && node . constructor . title_mode != LiteGraph . NO_TITLE ) {
36
49
let text = "" ;
37
50
if ( node . ty_et_execution_time !== undefined ) {
38
- text = formatExecutionTime ( node . ty_et_execution_time ) ;
51
+ text = formatExecutionTime ( node . ty_et_execution_time ) + " - vram " + formatBytes ( node . ty_et_vram_used , 2 ) ;
39
52
} else if ( node . ty_et_start_time !== undefined ) {
40
53
text = formatExecutionTime ( LiteGraph . getTime ( ) - node . ty_et_start_time ) ;
41
54
}
@@ -140,7 +153,8 @@ function buildTableHtml() {
140
153
$el ( "th" , { style : headerThStyle , "textContent" : "Node Title" } ) ,
141
154
$el ( "th" , { style : headerThStyle , "textContent" : "Current Time" } ) ,
142
155
$el ( "th" , { style : headerThStyle , "textContent" : "Per Time" } ) ,
143
- $el ( "th" , { style : headerThStyle , "textContent" : "Current / Pre Diff" } )
156
+ $el ( "th" , { style : headerThStyle , "textContent" : "Cur / Pre Time Diff" } ) ,
157
+ $el ( "th" , { style : headerThStyle , "textContent" : "VRAM Used" } )
144
158
] )
145
159
] ) ,
146
160
tableBody ,
@@ -170,6 +184,9 @@ function buildTableHtml() {
170
184
return [ diffColor , diffText ]
171
185
}
172
186
187
+ let max_execution_time = null
188
+ let max_vram_used = null
189
+
173
190
runningData . nodes_execution_time . forEach ( function ( item ) {
174
191
const nodeId = item . node ;
175
192
const node = app . graph . getNodeById ( nodeId )
@@ -178,7 +195,16 @@ function buildTableHtml() {
178
195
179
196
const [ diffColor , diffText ] = diff ( item . execution_time , preExecutionTime ) ;
180
197
198
+ if ( max_execution_time == null || item . execution_time > max_execution_time ) {
199
+ max_execution_time = item . execution_time
200
+ }
201
+
202
+ if ( max_vram_used == null || item . vram_used > max_vram_used ) {
203
+ max_vram_used = item . vram_used
204
+ }
205
+
181
206
tableBody . append ( $el ( "tr" , {
207
+ style : { "cursor" : "pointer" } ,
182
208
onclick : ( ) => {
183
209
if ( node ) {
184
210
app . canvas . selectNode ( node , false ) ;
@@ -199,10 +225,36 @@ function buildTableHtml() {
199
225
} ,
200
226
"textContent" : diffText
201
227
} ) ,
228
+ $el ( "td" , { style : { "textAlign" : "right" } , "textContent" : formatBytes ( item . vram_used , 2 ) } ) ,
202
229
] ) )
203
230
} ) ;
204
231
if ( runningData . total_execution_time !== null ) {
205
232
const [ diffColor , diffText ] = diff ( runningData . total_execution_time , lastRunningDate ?. total_execution_time ) ;
233
+
234
+ tableFooter . append ( $el ( "tr" , [
235
+ $el ( "td" , { style : { "textAlign" : "right" } , "textContent" : 'Max' } ) ,
236
+ $el ( "td" , { style : { "textAlign" : "right" } , "textContent" : '' } ) ,
237
+ $el ( "td" , {
238
+ style : { "textAlign" : "right" } ,
239
+ "textContent" : max_execution_time != null ? formatExecutionTime ( max_execution_time ) : ''
240
+ } ) ,
241
+ $el ( "td" , {
242
+ style : { "textAlign" : "right" } ,
243
+ "textContent" : ''
244
+ } ) ,
245
+ $el ( "td" , {
246
+ style : {
247
+ "textAlign" : "right" ,
248
+ "color" : diffColor
249
+ } ,
250
+ "textContent" : ''
251
+ } ) ,
252
+ $el ( "td" , {
253
+ style : { "textAlign" : "right" } ,
254
+ "textContent" : max_vram_used != null ? formatBytes ( max_vram_used , 2 ) : ''
255
+ } ) ,
256
+ ] ) )
257
+
206
258
tableFooter . append ( $el ( "tr" , [
207
259
$el ( "td" , { style : { "textAlign" : "right" } , "textContent" : 'Total' } ) ,
208
260
$el ( "td" , { style : { "textAlign" : "right" } , "textContent" : '' } ) ,
@@ -221,6 +273,7 @@ function buildTableHtml() {
221
273
} ,
222
274
"textContent" : diffText
223
275
} ) ,
276
+ $el ( "td" , { style : { "textAlign" : "right" } , "textContent" : "" } ) ,
224
277
] ) )
225
278
}
226
279
return table ;
@@ -261,11 +314,13 @@ app.registerExtension({
261
314
const node = app . graph . getNodeById ( detail . node )
262
315
if ( node ) {
263
316
node . ty_et_execution_time = detail . execution_time ;
317
+ node . ty_et_vram_used = detail . vram_used ;
264
318
}
265
319
const index = runningData . nodes_execution_time . findIndex ( x => x . node === detail . node ) ;
266
320
const data = {
267
321
node : detail . node ,
268
- execution_time : detail . execution_time
322
+ execution_time : detail . execution_time ,
323
+ vram_used : detail . vram_used
269
324
} ;
270
325
if ( index > 0 ) {
271
326
runningData . nodes_execution_time [ index ] = data
@@ -283,6 +338,7 @@ app.registerExtension({
283
338
app . graph . _nodes . forEach ( function ( node ) {
284
339
delete node . ty_et_start_time
285
340
delete node . ty_et_execution_time
341
+ delete node . ty_et_vram_used
286
342
} ) ;
287
343
runningData = {
288
344
nodes_execution_time : [ ] ,
@@ -337,7 +393,7 @@ app.registerExtension({
337
393
const thUnscaledHeight = 24 ;
338
394
const tableUnscaledHeight = thUnscaledHeight * tableHeight / thHeight ;
339
395
const autoResizeMaxHeight = 300 ;
340
- return [ Math . max ( originSize [ 0 ] , 480 ) , originSize [ 1 ] + Math . min ( tableUnscaledHeight , autoResizeMaxHeight ) - LiteGraph . NODE_WIDGET_HEIGHT ] ;
396
+ return [ Math . max ( originSize [ 0 ] , 600 ) , originSize [ 1 ] + Math . min ( tableUnscaledHeight , autoResizeMaxHeight ) - LiteGraph . NODE_WIDGET_HEIGHT ] ;
341
397
}
342
398
343
399
const nodeCreated = nodeType . prototype . onNodeCreated ;
0 commit comments