import { FrameStats , IModelApp , Tool } from "@itwin/core-frontend" ; /** Enable or disable (toggle) frame statistics reporting for all viewports. */ export class FrameStatsTool extends Tool { public static override toolId = "FrameStats" ; public static override get minArgs ( ) { return 0 ; } public static override get maxArgs ( ) { return 0 ; } public override async run ( ) { for ( const vp of IModelApp . viewManager ) { if ( vp . onFrameStats . numberOfListeners > 0 ) vp . onFrameStats . clear ( ) ; else vp . onFrameStats . addListener ( ( stats ) => { console . log ( `frame stats (vp=${ vp . viewportId }) = ${ JSON . stringify ( stats ) }` ) ; } ) ; } return true ; } public override async parseAndRun ( ... args ) { switch ( args . length ) { case 0 : return this . run ( ) ; } return true ; } }