Showing the changes to interface/src/Util.cpp (1 of 30 files). Show all
Unified · Split
| @@ -27,6 +27,7 @@ · 26 unmodified lines | |||
| 27 | #include "InterfaceConfig.h" | 27 | #include "InterfaceConfig.h" |
| 28 | #include "world.h" | 28 | #include "world.h" |
| 29 | #include "Application.h" | 29 | #include "Application.h" |
| 30 | #include "InterfaceLogging.h" | ||
| 30 | 31 | ||
| 31 | #include "Util.h" | 32 | #include "Util.h" |
| 32 | 33 | ||
| @@ -136,43 +137,43 @@ void runTimingTests() { · 103 unmodified lines | |||
| 136 | 137 | ||
| 137 | float NSEC_TO_USEC = 1.0f / 1000.0f; | 138 | float NSEC_TO_USEC = 1.0f / 1000.0f; |
| 138 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; | 139 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; |
| 139 | qDebug("QElapsedTimer::nsecElapsed() usecs: %f", elapsedUsecs); | 140 | qCDebug(interface, "QElapsedTimer::nsecElapsed() usecs: %f", elapsedUsecs); |
| 140 | 141 | ||
| 141 | // Test sleep functions for accuracy | 142 | // Test sleep functions for accuracy |
| 142 | startTime.start(); | 143 | startTime.start(); |
| 143 | QThread::msleep(1); | 144 | QThread::msleep(1); |
| 144 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; | 145 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; |
| 145 | qDebug("QThread::msleep(1) ms: %f", elapsedUsecs / 1000.0f); | 146 | qCDebug(interface, "QThread::msleep(1) ms: %f", elapsedUsecs / 1000.0f); |
| 146 | 147 | ||
| 147 | startTime.start(); | 148 | startTime.start(); |
| 148 | QThread::sleep(1); | 149 | QThread::sleep(1); |
| 149 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; | 150 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; |
| 150 | qDebug("QThread::sleep(1) ms: %f", elapsedUsecs / 1000.0f); | 151 | qCDebug(interface, "QThread::sleep(1) ms: %f", elapsedUsecs / 1000.0f); |
| 151 | 152 | ||
| 152 | startTime.start(); | 153 | startTime.start(); |
| 153 | usleep(1); | 154 | usleep(1); |
| 154 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; | 155 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; |
| 155 | qDebug("usleep(1) ms: %f", elapsedUsecs / 1000.0f); | 156 | qCDebug(interface, "usleep(1) ms: %f", elapsedUsecs / 1000.0f); |
| 156 | 157 | ||
| 157 | startTime.start(); | 158 | startTime.start(); |
| 158 | usleep(10); | 159 | usleep(10); |
| 159 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; | 160 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; |
| 160 | qDebug("usleep(10) ms: %f", elapsedUsecs / 1000.0f); | 161 | qCDebug(interface, "usleep(10) ms: %f", elapsedUsecs / 1000.0f); |
| 161 | 162 | ||
| 162 | startTime.start(); | 163 | startTime.start(); |
| 163 | usleep(100); | 164 | usleep(100); |
| 164 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; | 165 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; |
| 165 | qDebug("usleep(100) ms: %f", elapsedUsecs / 1000.0f); | 166 | qCDebug(interface, "usleep(100) ms: %f", elapsedUsecs / 1000.0f); |
| 166 | 167 | ||
| 167 | startTime.start(); | 168 | startTime.start(); |
| 168 | usleep(1000); | 169 | usleep(1000); |
| 169 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; | 170 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; |
| 170 | qDebug("usleep(1000) ms: %f", elapsedUsecs / 1000.0f); | 171 | qCDebug(interface, "usleep(1000) ms: %f", elapsedUsecs / 1000.0f); |
| 171 | 172 | ||
| 172 | startTime.start(); | 173 | startTime.start(); |
| 173 | usleep(15000); | 174 | usleep(15000); |
| 174 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; | 175 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; |
| 175 | qDebug("usleep(15000) ms: %f", elapsedUsecs / 1000.0f); | 176 | qCDebug(interface, "usleep(15000) ms: %f", elapsedUsecs / 1000.0f); |
| 176 | 177 | ||
| 177 | // Random number generation | 178 | // Random number generation |
| 178 | startTime.start(); | 179 | startTime.start(); |
| @@ -180,7 +181,7 @@ void runTimingTests() { · 1 unmodified line | |||
| 180 | iResults[i] = rand(); | 181 | iResults[i] = rand(); |
| 181 | } | 182 | } |
| 182 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; | 183 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; |
| 183 | qDebug("rand() stored in array usecs: %f, first result:%d", elapsedUsecs / (float) numTests, iResults[0]); | 184 | qCDebug(interface, "rand() stored in array usecs: %f, first result:%d", elapsedUsecs / (float) numTests, iResults[0]); |
| 184 | 185 | ||
| 185 | // Random number generation using randFloat() | 186 | // Random number generation using randFloat() |
| 186 | startTime.start(); | 187 | startTime.start(); |
| @@ -188,7 +189,7 @@ void runTimingTests() { · 1 unmodified line | |||
| 188 | fResults[i] = randFloat(); | 189 | fResults[i] = randFloat(); |
| 189 | } | 190 | } |
| 190 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; | 191 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; |
| 191 | qDebug("randFloat() stored in array usecs: %f, first result: %f", elapsedUsecs / (float) numTests, fResults[0]); | 192 | qCDebug(interface, "randFloat() stored in array usecs: %f, first result: %f", elapsedUsecs / (float) numTests, fResults[0]); |
| 192 | 193 | ||
| 193 | free(iResults); | 194 | free(iResults); |
| 194 | free(fResults); | 195 | free(fResults); |
| @@ -200,7 +201,7 @@ void runTimingTests() { · 5 unmodified lines | |||
| 200 | fTest = powf(fTest, 0.5f); | 201 | fTest = powf(fTest, 0.5f); |
| 201 | } | 202 | } |
| 202 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; | 203 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; |
| 203 | qDebug("powf(f, 0.5) usecs: %f", elapsedUsecs / (float) numTests); | 204 | qCDebug(interface, "powf(f, 0.5) usecs: %f", elapsedUsecs / (float) numTests); |
| 204 | 205 | ||
| 205 | // Vector Math | 206 | // Vector Math |
| 206 | float distance; | 207 | float distance; |
| @@ -212,7 +213,7 @@ void runTimingTests() { · 5 unmodified lines | |||
| 212 | distance = glm::distance(pointA, pointB); | 213 | distance = glm::distance(pointA, pointB); |
| 213 | } | 214 | } |
| 214 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; | 215 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; |
| 215 | qDebug("vector math usecs: %f [%f usecs total for %d tests], last result:%f", | 216 | qCDebug(interface, "vector math usecs: %f [%f usecs total for %d tests], last result:%f", |
| 216 | elapsedUsecs / (float) numTests, elapsedUsecs, numTests, distance); | 217 | elapsedUsecs / (float) numTests, elapsedUsecs, numTests, distance); |
| 217 | 218 | ||
| 218 | // Vec3 test | 219 | // Vec3 test |
| @@ -225,7 +226,7 @@ void runTimingTests() { · 6 unmodified lines | |||
| 225 | result = glm::dot(temp,temp); | 226 | result = glm::dot(temp,temp); |
| 226 | } | 227 | } |
| 227 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; | 228 | elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC; |
| 228 | qDebug("vec3 assign and dot() usecs: %f, last result:%f", elapsedUsecs / (float) numTests, result); | 229 | qCDebug(interface, "vec3 assign and dot() usecs: %f, last result:%f", elapsedUsecs / (float) numTests, result); |
| 229 | } | 230 | } |
| 230 | 231 | ||
| 231 | bool rayIntersectsSphere(const glm::vec3& rayStarting, const glm::vec3& rayNormalizedDirection, | 232 | bool rayIntersectsSphere(const glm::vec3& rayStarting, const glm::vec3& rayNormalizedDirection, |