Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: strange behavior in the update function  (Read 2087 times)

0 Members and 1 Guest are viewing this topic.

EGYPTIAN CODER

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
strange behavior in the update function
« on: December 07, 2016, 11:41:07 pm »
        void                                    update(sf::Time elapsedTime)
{
        std::cout<<"too slow right !!\n";
        mWorld.update(elapsedTime);
}
this is the function update from class(game) from SFML GAME DEVELOPMENT
I just added cout and then the game become tooooo slow 1 frame/second
I am in chapter three in the book and I have followed the instructions very well
before adding this cout and in this particular place every thing was good ???
« Last Edit: December 08, 2016, 07:55:10 am by Laurent »

jamesL

  • Full Member
  • ***
  • Posts: 124
    • View Profile
Re: strange behavior in the update function
« Reply #1 on: December 08, 2016, 12:29:58 am »
then take it out

it's not serving any purpose

EGYPTIAN CODER

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: strange behavior in the update function
« Reply #2 on: December 08, 2016, 12:45:45 am »
I know it is not serving any target but I just want to know why this happened
« Last Edit: December 08, 2016, 07:55:27 am by Laurent »

victorlevasseur

  • Full Member
  • ***
  • Posts: 206
    • View Profile
Re: strange behavior in the update function
« Reply #3 on: December 08, 2016, 01:42:31 am »
That's because std::cout is slow (but it shouldn't be that slow however).

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: strange behavior in the update function
« Reply #4 on: December 08, 2016, 08:45:36 pm »
std::cout is generally slow on Windows, even if you're not flushing content every line. How significant is the impact on your framerate? Note that dropping from 5,000 fps to 2,500 fps (or anything similar) is essentially "nothing".

EGYPTIAN CODER

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: strange behavior in the update function
« Reply #5 on: December 08, 2016, 10:58:04 pm »
I am just asking the question because its a very strange thing  that the frame rate drop to even less than
1 frame per second;
but if this is normal then  I will just remove std::cout and complete the project with no problems at all

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10783
    • View Profile
    • development blog
    • Email
strange behavior in the update function
« Reply #6 on: December 09, 2016, 08:18:27 am »
Having performance issues? Use a profiler to figure out why. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything