History

added warnings if bitstream processing takes too long

ZappoMan committed 13 years ago

Commit a6d2bb71 parent 6a7ebb31 file · +57 −0Browse files

Showing the changes to interface/src/VoxelSystem.cpp (1 of 1 file). Show all

Unified · Split

interface/src/VoxelSystem.cpp+57−0
@@ -97,8 +97,21 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 96 unmodified lines
9797
9898 switch(command) {
9999 case PACKET_HEADER_VOXEL_DATA:
100+ {
101+ double start = usecTimestampNow();
100102 // ask the VoxelTree to read the bitstream into the tree
101103 _tree->readBitstreamToTree(voxelData, numBytes - 1);
104+ double end = usecTimestampNow();
105+ double elapsedmsec = (end - start)/1000.0;
106+ if (elapsedmsec > 100) {
107+ if (elapsedmsec > 1000) {
108+ double elapsedsec = (end - start)/1000000.0;
109+ printLog("WARNING! readBitstreamToTree() took %lf seconds\n",elapsedsec);
110+ } else {
111+ printLog("WARNING! readBitstreamToTree() took %lf milliseconds\n",elapsedmsec);
112+ }
113+ }
114+ }
102115 break;
103116 case PACKET_HEADER_ERASE_VOXEL:
104117 // ask the tree to read the "remove" bitstream
@@ -135,16 +148,28 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) { · 30 unmodified lines
135148 }
136149
137150 void VoxelSystem::setupNewVoxelsForDrawing() {
151+ double start = usecTimestampNow();
138152 _voxelsUpdated = newTreeToArrays(_tree->rootNode);
139153 if (_voxelsUpdated) {
140154 _voxelsDirty=true;
141155 }
156+ double end = usecTimestampNow();
157+ double elapsedmsec = (end - start)/1000.0;
158+ if (elapsedmsec > 100) {
159+ if (elapsedmsec > 1000) {
160+ double elapsedsec = (end - start)/1000000.0;
161+ printLog("WARNING! newTreeToArrays() took %lf seconds\n",elapsedsec);
162+ } else {
163+ printLog("WARNING! newTreeToArrays() took %lf milliseconds\n",elapsedmsec);
164+ }
165+ }
142166
143167 // copy the newly written data to the arrays designated for reading
144168 copyWrittenDataToReadArrays();
145169 }
146170
147171 void VoxelSystem::copyWrittenDataToReadArrays() {
172+ double start = usecTimestampNow();
148173 if (_voxelsDirty) {
149174 // lock on the buffer write lock so we can't modify the data when the GPU is reading it
150175 pthread_mutex_lock(&_bufferWriteLock);
@@ -154,6 +179,16 @@ void VoxelSystem::copyWrittenDataToReadArrays() { · 3 unmodified lines
154179 memcpy(_readColorsArray, _writeColorsArray, bytesOfColors );
155180 pthread_mutex_unlock(&_bufferWriteLock);
156181 }
182+ double end = usecTimestampNow();
183+ double elapsedmsec = (end - start)/1000.0;
184+ if (elapsedmsec > 100) {
185+ if (elapsedmsec > 1000) {
186+ double elapsedsec = (end - start)/1000000.0;
187+ printLog("WARNING! copyWrittenDataToReadArrays() took %lf seconds\n",elapsedsec);
188+ } else {
189+ printLog("WARNING! copyWrittenDataToReadArrays() took %lf milliseconds\n",elapsedmsec);
190+ }
191+ }
157192 }
158193
159194 int VoxelSystem::newTreeToArrays(VoxelNode* node) {
@@ -296,6 +331,7 @@ void VoxelSystem::init() { · 136 unmodified lines
296331 }
297332
298333 void VoxelSystem::updateVBOs() {
334+ double start = usecTimestampNow();
299335 if (_voxelsDirty) {
300336 glBufferIndex segmentStart = 0;
301337 glBufferIndex segmentEnd = 0;
@@ -327,9 +363,20 @@ void VoxelSystem::updateVBOs() { · 25 unmodified lines
327363 }
328364 _voxelsDirty = false;
329365 }
366+ double end = usecTimestampNow();
367+ double elapsedmsec = (end - start)/1000.0;
368+ if (elapsedmsec > 100) {
369+ if (elapsedmsec > 1000) {
370+ double elapsedsec = (end - start)/1000000.0;
371+ printLog("WARNING! updateVBOs() took %lf seconds\n",elapsedsec);
372+ } else {
373+ printLog("WARNING! updateVBOs() took %lf milliseconds\n",elapsedmsec);
374+ }
375+ }
330376 }
331377
332378 void VoxelSystem::render() {
379+ double start = usecTimestampNow();
333380 glPushMatrix();
334381 updateVBOs();
335382 // tell OpenGL where to find vertex and color information
@@ -362,6 +409,16 @@ void VoxelSystem::render() { · 26 unmodified lines
362409
363410 // scale back down to 1 so heads aren't massive
364411 glPopMatrix();
412+ double end = usecTimestampNow();
413+ double elapsedmsec = (end - start)/1000.0;
414+ if (elapsedmsec > 100) {
415+ if (elapsedmsec > 1000) {
416+ double elapsedsec = (end - start)/1000000.0;
417+ printLog("WARNING! render() took %lf seconds\n",elapsedsec);
418+ } else {
419+ printLog("WARNING! render() took %lf milliseconds\n",elapsedmsec);
420+ }
421+ }
365422 }
366423
367424 int VoxelSystem::_nodeCount = 0;