# Performance of 3.0.3 worse than 2.7.7

**URL:** <https://discourse.glfw.org/t/performance-of-3-0-3-worse-than-2-7-7/544>\
**Category:** support\
**Created:** [September 25, 2013, 8:40pm UTC](https://discourse.glfw.org/t/performance-of-3-0-3-worse-than-2-7-7/544 "2013-09-25T20:40:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [September 25, 2013, 8:40pm UTC](https://discourse.glfw.org/t/performance-of-3-0-3-worse-than-2-7-7/544/1 "2013-09-25T20:40:52Z")

</div>

**[ant12](https://sourceforge.net/u/ant12/)** wrote on [Wednesday, September 25, 2013](https://sourceforge.net/p/glfw/discussion/247562/thread/06264df4/#b337):

I just moved from glfw-2.7.7 to glfw-3.0.3. My test application gets 50 FPS under 2.7.7 but only 20 FPS under 3.0.3. I’m running OS X 10.7.5.

```
// init
glfwOpenWindow(428*2, 240*2, 8,8,8,8,0,0, GLFW_WINDOW);

// tight loop
{
  glClear(GL_COLOR_BUFFER_BIT);
  glPixelZoom(2.0, 2.0);
  glDrawPixels(428, 240, GL_RGBA, GL_UNSIGNED_BYTE, &frame_buf_[0]);
  glfwSwapBuffers();
  if (glfwGetKey(GLFW_KEY_ESC) || !glfwGetWindowParam(GLFW_OPENED))
      break; // user chose to quit
}

```

Anyone know why this should be and what I can do to improve my app’s performance?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [September 27, 2013, 1:06pm UTC](https://discourse.glfw.org/t/performance-of-3-0-3-worse-than-2-7-7/544/2 "2013-09-27T13:06:34Z")

</div>

**[elmindreda](https://sourceforge.net/u/elmindreda/)** wrote on [Friday, September 27, 2013](https://sourceforge.net/p/glfw/discussion/247562/thread/06264df4/#f922):

Use a profiler to find out where the bottleneck lies.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [October 4, 2013, 8:28pm UTC](https://discourse.glfw.org/t/performance-of-3-0-3-worse-than-2-7-7/544/3 "2013-10-04T20:28:31Z")

</div>

**[ant12](https://sourceforge.net/u/ant12/)** wrote on [Friday, October 04, 2013](https://sourceforge.net/p/glfw/discussion/247562/thread/06264df4/#6480):

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [October 8, 2013, 9:35pm UTC](https://discourse.glfw.org/t/performance-of-3-0-3-worse-than-2-7-7/544/4 "2013-10-08T21:35:54Z")

</div>

**[ant12](https://sourceforge.net/u/ant12/)** wrote on [Tuesday, October 08, 2013](https://sourceforge.net/p/glfw/discussion/247562/thread/06264df4/#c349):

```
// 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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [October 12, 2013, 5:44pm UTC](https://discourse.glfw.org/t/performance-of-3-0-3-worse-than-2-7-7/544/5 "2013-10-12T17:44:35Z")

</div>

**[ant12](https://sourceforge.net/u/ant12/)** wrote on [Saturday, October 12, 2013](https://sourceforge.net/p/glfw/discussion/247562/thread/06264df4/#12da):

The problem was user error, as you might have expected.

Notice my test2 command line contains “-O2”?

Notice my test3 command line contains “-02”?

Sorry for wasting your time and I’m glad I haven’t in fact found a problem in 3.0.3.

Best wishes!
