title: SFML - sleep calculation
body: <p>I am working on a benchmark application that would compare SFML and SDL. One of the things I'm benchmarking is speed of playing sound. I play the sound many times in a loop and calculate the time it takes. I need a delay between playing sounds since I first need to finish playing a sound to start over again. I fixed this with SFML sleep, however I'm not sure if I'm doing it right. Probably not because after first play, the application freezes, like if it would be in an infinite loop. I need it to delay 1 millisecond if the music is still playing. Can you please help me out?</p>
  
  <p>My functions:</p>
  
  <pre><code>void playSound()
  {
      sound.setBuffer(buffer);
      sound.play();
  }
  
  void soundBenchmark(int numOfCycles)
  {
      sf::Time delayTime = sf::milliseconds(0.01);
      sf::Clock clock;
      for(int i = 0; i &lt; numOfCycles; i++)
      {
          playSound();
          while(sound.Playing) sf::sleep(delayTime);
      }
      sf::Time time = clock.getElapsedTime();
      cout &lt;&lt; "Time required for " &lt;&lt; numOfCycles &lt;&lt; " cycles playing sound: " &lt;&lt;  time.asMilliseconds() &lt;&lt; " milliseconds.\n";
  }
  </code></pre>
  
  <p>Calling the function in main:</p>
  
  <pre><code>while(running)
      {
          while(window.pollEvent(event))
          {
              if(event.type == sf::Event::Closed)
              {
                  window.close();
                  running = false;
              }
          }
          soundBenchmark(20);
          break;
      }
      return 0;
  </code></pre>