Hello Guest

glfwJoystickPresent takes too much time

  • 2 Replies
  • 6075 Views
glfwJoystickPresent takes too much time
« on: August 14, 2015, 14:40:32 »
In order to support controller hot-plugging I was cheking for present joysticks once per frame (now I do it once every second) and I realized that my frames per second droped from 4 digit numbers to a few 30 to 40.

I traked the isue to the glfwJoystickPresent call and benchmarked-it; now even with the every second fix y have small hickups every (...) second.

Fun fact, after I plug the first controller the cost almost disapears, I am using Windows 10, Inpiron 15 5000 series and a XBOXONE controller.

Is this a normal expected behaviour?

GLFW_JOYSTICK_1 : 19.112301
GLFW_JOYSTICK_2 : 0.038061
GLFW_JOYSTICK_3 : 0.024804
GLFW_JOYSTICK_4 : 0.025659
GLFW_JOYSTICK_5 : 0.021382
GLFW_JOYSTICK_6 : 0.019672
GLFW_JOYSTICK_7 : 0.020527
GLFW_JOYSTICK_8 : 0.019672
GLFW_JOYSTICK_9 : 0.022238
GLFW_JOYSTICK_10 : 0.022666
GLFW_JOYSTICK_11 : 0.023521
GLFW_JOYSTICK_12 : 0.022665
GLFW_JOYSTICK_13 : 0.020956
GLFW_JOYSTICK_14 : 0.021383
GLFW_JOYSTICK_15 : 0.021811
GLFW_JOYSTICK_16 : 0.024376

GLFW_JOYSTICK_1 : 0.004705
GLFW_JOYSTICK_2 : 0.063721
GLFW_JOYSTICK_3 : 0.026942
GLFW_JOYSTICK_4 : 0.024377
GLFW_JOYSTICK_5 : 0.023093
GLFW_JOYSTICK_6 : 0.021383
GLFW_JOYSTICK_7 : 0.014968
GLFW_JOYSTICK_8 : 0.01454
GLFW_JOYSTICK_9 : 0.013685
GLFW_JOYSTICK_10 : 0.01454
GLFW_JOYSTICK_11 : 0.014112
GLFW_JOYSTICK_12 : 0.01454
GLFW_JOYSTICK_13 : 0.014112
GLFW_JOYSTICK_14 : 0.013685
GLFW_JOYSTICK_15 : 0.013685
GLFW_JOYSTICK_16 : 0.014112
EL JOYSTICK_0 (Microsoft PC-joystick driver) SE HA CONECTADO

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: glfwJoystickPresent takes too much time
« Reply #1 on: August 14, 2015, 17:04:41 »
Not sure. I tested this:

Code: [Select]
for ( int i = 0; i < GLFW_JOYSTICK_LAST; i++ ) {
glfwJoystickPresent(i);
}
it takes ~100μs on my machine (Windows 10). glfwJoystickPresent is calling this function on Windows (checks if it returns JOYERR_NOERROR).

Re: glfwJoystickPresent takes too much time
« Reply #2 on: August 14, 2015, 17:12:38 »
It must be my machine then, my code is roughly the same as yours; I'll take my precautions

Code: [Select]
for (int i = 0; i < joysticks.length; i++)
    joysticks[i].present = glfwJoystickPresent(i) == GL_TRUE;
« Last Edit: August 14, 2015, 20:40:54 by bardackx »