Merge pull request #2976 from talentraspel/19751

dynamically malloc/free arrays to avoid stack overflow on windows.
This commit is contained in:
Brad Hefta-Gaub 2014-06-03 12:10:44 -07:00
commit 03f0ff111f

View file

@ -400,9 +400,9 @@ bool closeEnoughForGovernmentWork(float a, float b) {
void runTimingTests() {
// How long does it take to make a call to get the time?
const int numTests = 1000000;
int iResults[numTests];
int* iResults = (int*)malloc(sizeof(int) * numTests);
float fTest = 1.0;
float fResults[numTests];
float* fResults = (float*)malloc(sizeof(float) * numTests);
QElapsedTimer startTime;
startTime.start();
float elapsedUsecs;
@ -413,7 +413,7 @@ void runTimingTests() {
// Random number generation
startTime.start();
for (int i = 1; i < numTests; i++) {
for (int i = 0; i < numTests; i++) {
iResults[i] = rand();
}
elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC;
@ -421,16 +421,19 @@ void runTimingTests() {
// Random number generation using randFloat()
startTime.start();
for (int i = 1; i < numTests; i++) {
for (int i = 0; i < numTests; i++) {
fResults[i] = randFloat();
}
elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC;
qDebug("randFloat() stored in array usecs: %f, first result: %f", elapsedUsecs / (float) numTests, fResults[0]);
free(iResults);
free(fResults);
// PowF function
fTest = 1145323.2342f;
startTime.start();
for (int i = 1; i < numTests; i++) {
for (int i = 0; i < numTests; i++) {
fTest = powf(fTest, 0.5f);
}
elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC;
@ -440,7 +443,7 @@ void runTimingTests() {
float distance;
glm::vec3 pointA(randVector()), pointB(randVector());
startTime.start();
for (int i = 1; i < numTests; i++) {
for (int i = 0; i < numTests; i++) {
//glm::vec3 temp = pointA - pointB;
//float distanceSquared = glm::dot(temp, temp);
distance = glm::distance(pointA, pointB);
@ -454,7 +457,7 @@ void runTimingTests() {
float result;
startTime.start();
for (int i = 1; i < numTests; i++) {
for (int i = 0; i < numTests; i++) {
glm::vec3 temp = vecA-vecB;
result = glm::dot(temp,temp);
}