mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 15:09:24 +02:00
dynamically malloc/free arrays to avoid stack overflow on windows.
starting with 0 for array index will give a reasonable value for 'first'.
This commit is contained in:
parent
6f5d2ba233
commit
162939fda1
1 changed files with 10 additions and 7 deletions
|
@ -400,9 +400,9 @@ bool closeEnoughForGovernmentWork(float a, float b) {
|
||||||
void runTimingTests() {
|
void runTimingTests() {
|
||||||
// How long does it take to make a call to get the time?
|
// How long does it take to make a call to get the time?
|
||||||
const int numTests = 1000000;
|
const int numTests = 1000000;
|
||||||
int iResults[numTests];
|
int* iResults = (int*)malloc(sizeof(int) * numTests);
|
||||||
float fTest = 1.0;
|
float fTest = 1.0;
|
||||||
float fResults[numTests];
|
float* fResults = (float*)malloc(sizeof(float) * numTests);
|
||||||
QElapsedTimer startTime;
|
QElapsedTimer startTime;
|
||||||
startTime.start();
|
startTime.start();
|
||||||
float elapsedUsecs;
|
float elapsedUsecs;
|
||||||
|
@ -413,7 +413,7 @@ void runTimingTests() {
|
||||||
|
|
||||||
// Random number generation
|
// Random number generation
|
||||||
startTime.start();
|
startTime.start();
|
||||||
for (int i = 1; i < numTests; i++) {
|
for (int i = 0; i < numTests; i++) {
|
||||||
iResults[i] = rand();
|
iResults[i] = rand();
|
||||||
}
|
}
|
||||||
elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC;
|
elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC;
|
||||||
|
@ -421,16 +421,19 @@ void runTimingTests() {
|
||||||
|
|
||||||
// Random number generation using randFloat()
|
// Random number generation using randFloat()
|
||||||
startTime.start();
|
startTime.start();
|
||||||
for (int i = 1; i < numTests; i++) {
|
for (int i = 0; i < numTests; i++) {
|
||||||
fResults[i] = randFloat();
|
fResults[i] = randFloat();
|
||||||
}
|
}
|
||||||
elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC;
|
elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC;
|
||||||
qDebug("randFloat() stored in array usecs: %f, first result: %f", elapsedUsecs / (float) numTests, fResults[0]);
|
qDebug("randFloat() stored in array usecs: %f, first result: %f", elapsedUsecs / (float) numTests, fResults[0]);
|
||||||
|
|
||||||
|
free(iResults);
|
||||||
|
free(fResults);
|
||||||
|
|
||||||
// PowF function
|
// PowF function
|
||||||
fTest = 1145323.2342f;
|
fTest = 1145323.2342f;
|
||||||
startTime.start();
|
startTime.start();
|
||||||
for (int i = 1; i < numTests; i++) {
|
for (int i = 0; i < numTests; i++) {
|
||||||
fTest = powf(fTest, 0.5f);
|
fTest = powf(fTest, 0.5f);
|
||||||
}
|
}
|
||||||
elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC;
|
elapsedUsecs = (float)startTime.nsecsElapsed() * NSEC_TO_USEC;
|
||||||
|
@ -440,7 +443,7 @@ void runTimingTests() {
|
||||||
float distance;
|
float distance;
|
||||||
glm::vec3 pointA(randVector()), pointB(randVector());
|
glm::vec3 pointA(randVector()), pointB(randVector());
|
||||||
startTime.start();
|
startTime.start();
|
||||||
for (int i = 1; i < numTests; i++) {
|
for (int i = 0; i < numTests; i++) {
|
||||||
//glm::vec3 temp = pointA - pointB;
|
//glm::vec3 temp = pointA - pointB;
|
||||||
//float distanceSquared = glm::dot(temp, temp);
|
//float distanceSquared = glm::dot(temp, temp);
|
||||||
distance = glm::distance(pointA, pointB);
|
distance = glm::distance(pointA, pointB);
|
||||||
|
@ -454,7 +457,7 @@ void runTimingTests() {
|
||||||
float result;
|
float result;
|
||||||
|
|
||||||
startTime.start();
|
startTime.start();
|
||||||
for (int i = 1; i < numTests; i++) {
|
for (int i = 0; i < numTests; i++) {
|
||||||
glm::vec3 temp = vecA-vecB;
|
glm::vec3 temp = vecA-vecB;
|
||||||
result = glm::dot(temp,temp);
|
result = glm::dot(temp,temp);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue