That’s a good idea. I had a quick look with XCode Instruments, but got distracted by the fact that I could no longer build the code shown above on Windows with GLFW 3.0.3 because glfwOpenWindow and glfwGetWindowParam no longer exist. So, how come I can still compile and link under OS X? I’m now confused and will need to investigate.
// test2.cpp
#include <GL/glfw.h>
#include <cmath>
int main()
{
if (glfwInit()) {
glfwOpenWindow(100, 100, 8,8,8,8,0,0, GLFW_WINDOW);
glfwTerminate();
}
float f = 1.234;
for (long long i = 0; i < 1000000000; ++i)
f = floor(f);
return (int)f;
}
$g++ -O2 -g -I/Projects/glfw-2.7.7/include -o test2 test2.cpp /Projects/glfw-2.7.7/lib/cocoa/libglfw.a -framework Cocoa -framework OpenGL -framework IOKit
$time ./test2
real 0m5.748s
user 0m5.487s
sys 0m0.093s
Result for GLFW 2.7.7 5.5 seconds
// test3.cpp
#include <GLFW/glfw3.h>
#include <cmath>
int main()
{
if (glfwInit()) {
glfwCreateWindow(100, 100, "hello", 0, 0);
glfwTerminate();
}
float f = 1.234;
for (long long i = 0; i < 1000000000; ++i)
f = floor(f);
return (int)f;
}
$g++ -02 -g -o test3 test3.cpp -lglfw3 -framework Cocoa -framework OpenGL -framework IOKit
$time ./test3
real 0m10.251s
user 0m10.038s
sys 0m0.043s
Result for GLFW 3.0.3 10 seconds
It seems that linking to 2.7.7 under OS X with the i686-apple-darwin11-llvm-g+±4.2 compiler floorf() is used. Whereas linking to 3.0.3 floor() is used, which takes twice as long. (I used Instruments and can see the different functions being called.) This is the cause of the performance slowdown in my application
after moving to 3.0.3.
Anyone have any suggestions on how to change this? I built both 2.7.7 and 3.0.3 from source. Are there build switches I’m not aware of that may be causing this difference.