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

Author Topic: C#/C++ build comparison  (Read 8383 times)

0 Members and 1 Guest are viewing this topic.

Bobbo

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: C#/C++ build comparison
« Reply #15 on: March 07, 2015, 08:11:12 pm »
Without seeing the code it's all just random guessing.. And my crystal ball is not being helpful atm.
If you want to see where time is spent, try a profiler...

As per my last post, the hello world program.

Here's the adjusted C# version:

static void Main()
        {
                RenderWindow window = new RenderWindow(new VideoMode(200, 200), "SFML works!");
           
                CircleShape shape = new CircleShape(100);
                shape.FillColor = Color.Green;

                Stopwatch clock = new Stopwatch();
            clock.Start();
                long frames = 0;

                while (window.IsOpen())
                {
                        window.DispatchEvents();
                       
                        if (clock.Elapsed.Seconds >= 30)
                        {
                    Console.Write(frames.ToString() + " in " + clock.ElapsedMilliseconds.ToString() + "ms");
                                break;
                        }

                        frames++;

                        window.Clear();
                        window.Draw(shape);
                        window.Display();
                }
        }

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: C#/C++ build comparison
« Reply #16 on: March 07, 2015, 08:16:02 pm »
It is not. I misread your code and removed my post when I realized (after about 20sec).

Bobbo

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: C#/C++ build comparison
« Reply #17 on: March 07, 2015, 08:16:35 pm »
It is not. I misread your code and removed my post when I realized (after about 20sec).

No worries, I have done the same.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: C#/C++ build comparison
« Reply #18 on: March 07, 2015, 08:57:37 pm »
This code does nothing. Add some stuff to your loop, like drawing 50000 entities. Otherwise, the surrounding "noise" (ie. negligible calls that you don't want to test) will have a non-negligible impact on the overall result.

But trust me, all languages will give the same results as long as you are testing a binding. Because all the time-consuming operations are done in the core C++ library (or in this case, even in the OpenGL driver itself). Don't waste your time.
« Last Edit: March 07, 2015, 08:59:26 pm by Laurent »
Laurent Gomila - SFML developer