@@ -31,11 +31,11 @@ function Debug(view, viewerDiv) {
3131 chartDiv . appendChild ( rightChart ) ;
3232
3333 // line graph for nb elements
34- const nbObjectsCanvas = document . createElement ( 'canvas' ) ;
35- nbObjectsCanvas . heigth = '20rem' ;
36- nbObjectsCanvas . width = '50vw' ;
37- nbObjectsCanvas . id = 'nb-objects' ;
38- leftChart . appendChild ( nbObjectsCanvas ) ;
34+ const viewChartCanvas = document . createElement ( 'canvas' ) ;
35+ viewChartCanvas . heigth = '20rem' ;
36+ viewChartCanvas . width = '50vw' ;
37+ viewChartCanvas . id = 'nb-objects' ;
38+ leftChart . appendChild ( viewChartCanvas ) ;
3939
4040 // bar graph for nb visible elements
4141 const nbVisibleCanvas = document . createElement ( 'canvas' ) ;
@@ -45,15 +45,14 @@ function Debug(view, viewerDiv) {
4545 rightChart . appendChild ( nbVisibleCanvas ) ;
4646
4747 const timestamp = Date . now ( ) ;
48- const nbObjectsDataset = { label : 'Number of objects in Scene' , data : [ { x : 0 , y : 0 } ] } ;
49- const nbVisibleDataset = { label : 'Number of visible objects in Scene' , data : [ { x : 0 , y : 0 } ] , borderColor : 'rgba(75,192,192,1)' } ;
50- const nbDisplayedDataset = { label : 'Number of displayed objects in Scene' , data : [ { x : 0 , y : 0 } ] , borderColor : 'rgba(153, 102, 255, 1)' } ;
51- const nbObjectsChartLabel = [ '0s' ] ;
48+ const viewLevelStartDataset = { label : 'Update 1st level' , data : [ { x : 0 , y : 0 } ] } ;
49+ const viewUpdateDurationDataset = { label : 'Update duration (ms)' , data : [ { x : 0 , y : 0 } ] , borderColor : 'rgba(75,192,192,1)' } ;
50+ const viewInfoChartLabel = [ '0s' ] ;
5251 const nbObjectsChart = new Chart ( 'nb-objects' , {
5352 type : 'line' ,
5453 data : {
55- labels : nbObjectsChartLabel ,
56- datasets : [ nbObjectsDataset , nbVisibleDataset , nbDisplayedDataset ] ,
54+ labels : viewInfoChartLabel ,
55+ datasets : [ viewLevelStartDataset , viewUpdateDurationDataset ] ,
5756 } ,
5857 options : {
5958 animation : { duration : 10 } ,
@@ -99,20 +98,7 @@ function Debug(view, viewerDiv) {
9998 } ,
10099 } ) ;
101100
102- function debugChartUpdate ( ) {
103- function countElem ( node ) {
104- if ( ! node ) {
105- return 0 ;
106- }
107- let count = 1 ; // this node
108- if ( node . children ) {
109- for ( const child of node . children ) {
110- count += countElem ( child ) ;
111- }
112- }
113- return count ;
114- }
115-
101+ function debugChartUpdate ( updateStartLevel , updateDuration ) {
116102 function countVisible ( node , stats ) {
117103 if ( ! node || ! node . visible ) {
118104 return ;
@@ -137,54 +123,40 @@ function Debug(view, viewerDiv) {
137123 // update bar graph
138124 const stats = { } ;
139125 countVisible ( view . mainLoop . gfxEngine . scene3D , stats ) ;
140- let totalVisible = 0 ;
141- let totalDisplayed = 0 ;
142126 nbVisibleLabels . length = 0 ;
143127 nbVisibleData . length = 0 ;
144128 for ( const level in stats ) {
145129 if ( { } . hasOwnProperty . call ( stats , level ) ) {
146130 nbVisibleLabels [ level - 1 ] = `${ level } ` ;
147131 nbVisibleData [ level - 1 ] = stats [ level ] [ 0 ] ;
148132 nbDisplayedData [ level - 1 ] = stats [ level ] [ 1 ] ;
149- totalVisible += stats [ level ] [ 0 ] ;
150- totalDisplayed += stats [ level ] [ 1 ] ;
151133 }
152134 }
153135
154136
155137 // update line graph
156- const newCount = countElem ( view . mainLoop . gfxEngine . scene3D ) ;
157-
158- // test if we values didn't change
159- if ( nbObjectsDataset . data . length > 1 ) {
160- const last = nbObjectsDataset . data . length - 1 ;
161- if ( nbObjectsDataset . data [ last ] . y === newCount &&
162- nbVisibleDataset . data [ last ] . y === totalVisible &&
163- nbDisplayedDataset . data [ last ] . y === totalDisplayed ) {
164- // nothing change: drop the last point, to keep more interesting (changing)
165- // data displayed
166- nbObjectsDataset . data . pop ( ) ;
167- nbVisibleDataset . data . pop ( ) ;
168- nbDisplayedDataset . data . pop ( ) ;
169- nbObjectsChartLabel . pop ( ) ;
170- }
171- }
172-
173138 // update time
174- const limit = 25 ;
139+ const limit = 60 ;
175140 const timeInS = Math . floor ( ( Date . now ( ) - timestamp ) / 1000 ) ;
176- nbObjectsChartLabel . push ( `${ timeInS } s` ) ;
177- if ( nbObjectsChartLabel . length > limit ) {
178- nbObjectsChartLabel . shift ( ) ;
141+ const lbl = `${ timeInS } s` ;
142+ const identical = ( viewInfoChartLabel . lastValidCompareIndex > 0 && viewInfoChartLabel [ viewInfoChartLabel . lastValidCompareIndex ] == lbl ) ;
143+ if ( identical ) {
144+ viewInfoChartLabel . push ( '' ) ;
145+ } else {
146+ viewInfoChartLabel . push ( lbl ) ;
147+ viewInfoChartLabel . lastValidCompareIndex = viewInfoChartLabel . length - 1 ;
179148 }
180149
181- nbObjectsDataset . data . push ( { x : timeInS , y : newCount } ) ;
182- nbVisibleDataset . data . push ( { x : timeInS , y : totalVisible } ) ;
183- nbDisplayedDataset . data . push ( { x : timeInS , y : totalDisplayed } ) ;
184- if ( nbObjectsDataset . data . length > limit ) {
185- nbObjectsDataset . data . shift ( ) ;
186- nbVisibleDataset . data . shift ( ) ;
187- nbDisplayedDataset . data . shift ( ) ;
150+ if ( viewInfoChartLabel . length > limit ) {
151+ viewInfoChartLabel . shift ( ) ;
152+ viewInfoChartLabel . lastValidCompareIndex -- ;
153+ }
154+
155+ viewLevelStartDataset . data . push ( { x : timeInS , y : updateStartLevel } ) ;
156+ viewUpdateDurationDataset . data . push ( { x : timeInS , y : updateDuration } ) ;
157+ if ( viewLevelStartDataset . data . length > limit ) {
158+ viewLevelStartDataset . data . shift ( ) ;
159+ viewUpdateDurationDataset . data . shift ( ) ;
188160 }
189161
190162 if ( chartDiv . style . display != 'none' ) {
@@ -280,11 +252,14 @@ function Debug(view, viewerDiv) {
280252 // hook that to scene.update
281253 const ml = view . mainLoop ;
282254 const oldUpdate = Object . getPrototypeOf ( ml ) . _update . bind ( ml ) ;
283- ml . _update = function debugUpdate ( view ) {
255+ ml . _update = function debugUpdate ( view , ... args ) {
284256 // regular itowns update
285- oldUpdate ( view ) ;
257+ const before = Date . now ( ) ;
258+ oldUpdate ( view , ...args ) ;
259+ const duration = Date . now ( ) - before ;
286260 // debug graphs update
287- debugChartUpdate ( ) ;
261+ debugChartUpdate ( view . _latestUpdateStartingLevel , duration ) ;
262+
288263 // obb layer update
289264 for ( const gLayer of view . _layers ) {
290265 const obbLayerAlreadyAdded =
0 commit comments