SFML community forums

General => General discussions => Topic started by: Laurent on August 28, 2007, 02:41:56 pm

Title: Benchmark : SDL vs SFML
Post by: Laurent on August 28, 2007, 02:41:56 pm
Hi everybody

A lot of people wonder how SFML compares to SDL, that's why I wrote a small benchmark to compare a few key features, mainly displaying sprites and text.

The tests consists of counting the number of frames rendered during 5 seconds :

1/ Displaying 2000 static sprites
2/ Displaying 2000 alpha-blended static sprites
3/ Displaying 2000 rotating sprites
4/ Displaying 20 lines of static text
5/ Displaying 20 lines of dynamic text

I used SDL_gfx for sprites rotations and SDL_ttf for displaying text. The latest versions of these libraries, as well as SDL, were used.

Source code + binaries + images + VS2005 files can be downloaded here :
http://sfml.sourceforge.net/temp/bench-sdl-sfml.zip (1.15 Mo)

Here are the results on a high configuration (AMD Athlon 64 DualCore 3800+, GeForce 7800 GT, 1 Go de RAM, Windows XP) :
Code: [Select]
1/ Test : sprites
SDL  displayed 9 frames
SFML displayed 303 frames
--> SFML is 3366% faster than SDL

2/ Test : alpha-blended sprites
SDL  displayed 5 frames
SFML displayed 216 frames
--> SFML is 4320% faster than SDL

3/ Test : rotating sprites
SDL  displayed 3 frames
SFML displayed 277 frames
--> SFML is 9233% faster than SDL

4/ Test : static text
SDL  displayed 416 frames
SFML displayed 6092 frames
--> SFML is 1464% faster than SDL

5/ Test : dynamic text
SDL  displayed 363 frames
SFML displayed 948 frames
--> SFML is 261% faster than SDL

Results on Linux with the same config are similar (a bit better for SFML).

Here are the results on a low configuration (Intel Pentium M 1.73 Ghz, integrated GPU Intel 915GM, 256 Mo de RAM, Windows XP) :
Code: [Select]
1/ Test : sprites
SDL  displayed 8 frames
SFML displayed 21 frames
--> SFML is 262% faster than SDL

2/ Test : alpha-blended sprites
SDL  displayed 5 frames
SFML displayed 21 frames
--> SFML is 420% faster than SDL

3/ Test : rotating sprites
SDL  displayed 2 frames
SFML displayed 15 frames
--> SFML is 750% faster than SDL

4/ Test : static text
SDL  displayed 885 frames
SFML displayed 774 frames
--> SFML is 13% slower than SDL

5/ Test : dynamic text
SDL  displayed 628 frames
SFML displayed 797 frames
--> SFML is 126% faster than SDL


As you can see SFML is faster than SDL, and it has to do with the use of OpenGL for getting hardware acceleration. Moreover, the 2D part of SFML has not been heavily optimized, and could be faster if needed.

If you have any question or suggestion about this benchmark, or any idea for something else to compare, feel free to discuss it here.
Title: Benchmark : SDL vs SFML
Post by: lubos on August 28, 2007, 03:05:52 pm
Very nice  :D

WinXP SP2, intel p4 1.8ghz, 512bm ram, ati radeon 7500:

Code: [Select]

SFML displayed 14 frames
--> SFML is 466% faster than SDL

2/ Test : alpha-blended sprites
SDL  displayed 3 frames
SFML displayed 14 frames
--> SFML is 466% faster than SDL

3/ Test : rotating sprites
SDL  displayed 2 frames
SFML displayed 14 frames
--> SFML is 700% faster than SDL

4/ Test : static text
SDL  displayed 408 frames
SFML displayed 641 frames
--> SFML is 157% faster than SDL

5/ Test : dynamic text
SDL  displayed 310 frames
SFML displayed 453 frames
--> SFML is 146% faster than SDL
Title: Benchmark : SDL vs SFML
Post by: Hiura on August 28, 2007, 05:15:49 pm
With my PC :
Quote
Config
Mainboard socket AM2 : ASRock ALiveSata2-GLAN
CPU  socket AM2 : Athlon 64 X2 4200+
Memory : 2X 512 MB DDR2
Harddisk 3.5" S-ATAII 7200rpm
Graphic Card : ATI His Exaclibur Radeon X1650 256 MB
OS : XP Home


Code: [Select]
1/ Test : sprites
SDL  displayed 10 frames
SFML displayed 111 frames
--> SFML is 1110% faster than SD

2/ Test : alpha-blended sprites
SDL  displayed 6 frames
SFML displayed 111 frames
--> SFML is 1850% faster than SD

3/ Test : rotating sprites
SDL  displayed 3 frames
SFML displayed 111 frames
--> SFML is 3700% faster than SD

4/ Test : static text
SDL  displayed 915 frames
SFML displayed 3953 frames
--> SFML is 432% faster than SDL

5/ Test : dynamic text
SDL  displayed 718 frames
SFML displayed 1026 frames
--> SFML is 142% faster than SDL


Hiura
Title: Benchmark : SDL vs SFML
Post by: CareBear on September 07, 2007, 04:32:49 pm
I'd run the test 3 times in a row. The result is from the last test.

My Machine
Quote
AMD Athlon X2 3800+ EE
2 GB DDR2-800 Ram in dual channel
GeForce 7600 GT
Asus Motherboard with nForce 570 ultra chipset
Windows XP 64bit edition


Result
Quote
1/ Test : sprites
SDL  displayed 9 frames
SFML displayed 313 frames
--> SFML is 3477% faster than SDL

2/ Test : alpha-blended sprites
SDL  displayed 6 frames
SFML displayed 238 frames
--> SFML is 3966% faster than SDL

3/ Test : rotating sprites
SDL  displayed 3 frames
SFML displayed 278 frames
--> SFML is 9266% faster than SDL

4/ Test : static text
SDL  displayed 942 frames
SFML displayed 9795 frames
--> SFML is 1039% faster than SDL

5/ Test : dynamic text
SDL  displayed 729 frames
SFML displayed 999 frames
--> SFML is 137% faster than SDL
Title: Getting on board with editing SFML to make it faster
Post by: Pwndja on September 09, 2007, 03:20:52 am
Hi I was wondering if I could help with the development of SFML? I am very interested in making it faster. I like that it is faster than SDL, which is the gaming lib that I was using until I found SFML. O by the way when using the dynamic DLLs for audio in VS it crashes after the program exits... I think you already talked about it in another form post but I'm not sure... just thought i would mention that...

let me know if I can help develop SFML I am a Junior in college taking a course now on Operating Systems and have had around 6-7 years programming experience.

thanks
Title: Benchmark : SDL vs SFML
Post by: Laurent on September 09, 2007, 11:04:19 am
Hi

I currently don't need much help to develop the core libraries. However, if you are interested in porting it to a new operating system or language, it would be very helpful.

About the audio crash, it's already fixed for the next release.

Thanks
Title: Benchmark : SDL vs SFML
Post by: Henrik.Flink on September 09, 2007, 11:43:58 am
My Machine
Quote
AMD Athlon 64 X2 Dual Core 6000+ 3.00GHz
2 GB DDR2-800 Ram
GeForce 8800GTS
MSI Motherboard with nForce 560
Windows Vista


Result
Quote

1/ Test : sprites
SDL  displayed 13 frames
SFML displayed 516 frames
--> SFML is 3969% faster than SDL

2/ Test : alpha-blended sprites
SDL  displayed 8 frames
SFML displayed 543 frames
--> SFML is 6787% faster than SDL

3/ Test : rotating sprites
SDL  displayed 4 frames
SFML displayed 562 frames
--> SFML is 14050% faster than SDL

4/ Test : static text
SDL  displayed 1106 frames
SFML displayed 8417 frames
--> SFML is 761% faster than SDL

5/ Test : dynamic text
SDL  displayed 894 frames
SFML displayed 1318 frames
--> SFML is 147% faster than SDL
Title: Benchmark : SDL vs SFML
Post by: Srejv on September 10, 2007, 11:15:34 am
Isn't there some way to optimize dynamic text? Or are strings too slow to begin with?
Title: Benchmark : SDL vs SFML
Post by: Laurent on September 10, 2007, 11:28:19 am
Dynamic text can be optimized if needed.
Title: Benchmark : SDL vs SFML
Post by: FallingSky on October 11, 2007, 05:47:14 pm
Im porting over a project of mine from SDL to SFML which involves almost nothing but dynamic text.  The FPS gets very low on my machine using SDL so I was wondering if you could take into consideration optimizing dynamic text?  I would greatly appreciate it but theres no rush!

Thanks
Title: Benchmark : SDL vs SFML
Post by: Laurent on October 12, 2007, 03:19:10 am
It would first be interestring to see how much FPS you can get without further optimization. If it's really too low, I'll try to make it a priority.
Title: Update SDL vs SFML benchmark to work w/ newer SFML builds
Post by: skylen on May 07, 2008, 09:38:17 pm
I have updated Laurent's benchmark to work with newer SFML builds. This one was made to work with and tested against SFML svn rev 651 (2008-05-03 15:05:43 -0700). I have here a patch against Laurent's ZIP file and a source tarball of my own. I added a Makefile for Linux (builds into a "bin/" subdirectory) and fixed the name of an SDL include file that had incorrect case (but worked on case-insensitive filesystems).

Patch (including bzr merge directive and bundle):
http://gibibit.com/upload/bench-sdl-sfml-update-20080507.patch

Source tarball:
http://gibibit.com/upload/bench-sdl-sfml-update-20080507.tar.bz2

Bazaar VCS (bzr) repository tarball:
http://gibibit.com/upload/bench-sdl-sfml-repo.tar.bz2

-Colin
Title: Benchmark : SDL vs SFML
Post by: JDieskau on May 12, 2008, 12:53:35 pm
Benchmark: 20080507
SFML Version: latest svn
SDL: 1.2.11

My maschine:
Quote
AMD Athlon 64 X2 Dual Core 6000+ 3.00GHz
2 GB DDR2-800 Ram
GeForce 8500GT
Ubuntu Linux ( 2.6.22-14-generic )


Result:
Quote
1/ Test : sprites
SDL  displayed 20 frames
SFML displayed 137 frames
--> SFML is 685% faster than SDL

2/ Test : alpha-blended sprites
SDL  displayed 7 frames
SFML displayed 98 frames
--> SFML is 1400% faster than SDL

3/ Test : rotating sprites
SDL  displayed 4 frames
SFML displayed 134 frames
--> SFML is 3350% faster than SDL

4/ Test : static text
SDL  displayed 1267 frames
SFML displayed 4600 frames
--> SFML is 363% faster than SDL

5/ Test : dynamic text
SDL  displayed 1020 frames
SFML displayed 1625 frames
--> SFML is 159% faster than SDL
Title: Benchmark : SDL vs SFML
Post by: Hnefi on May 14, 2008, 09:55:42 am
Your benchmarks are severly flawed. You are comparing the software, 2D library that ships with SDL to OpenGL. Of course you are going to get a huge difference in performance - you don't even need to perform a benchmark to understand that.

What would be really interesting is to see how an SDL-driven OpenGL application performs compared to SFML. That would be a meaningful test, for two reasons: it compares similar technologies and it benchmarks against SDL the way SDL is almost always used.
Title: Benchmark : SDL vs SFML
Post by: Laurent on May 14, 2008, 03:47:01 pm
Quote
Your benchmarks are severly flawed. You are comparing the software, 2D library that ships with SDL to OpenGL. Of course you are going to get a huge difference in performance - you don't even need to perform a benchmark to understand that.

I perfectly know that, this benchmark is basically just for beginners who might not be aware of the technical details, and wonder how SFML compares to a well known multimedia library.
At first I didn't want to do this benchmark, I did it only to answer the several requests I got from users.

Quote
What would be really interesting is to see how an SDL-driven OpenGL application performs compared to SFML. That would be a meaningful test, for two reasons: it compares similar technologies and it benchmarks against SDL the way SDL is almost always used.

I don't think so. OpenGL with GLUT, SFML or SDL will just be OpenGL ; in this case the library is used only to create a valid context, there's nothing to benchmark after initialization other than OpenGL calls.

This benchmark also demonstrates that it's possible to use only SFML for 2D rendering, there's no need for mixing with OpenGL like with SDL. SFML is a truly usable 2D API, it's not just there for prototyping.
Title: Benchmark : SDL vs SFML
Post by: workmad3 on May 14, 2008, 04:17:24 pm
It's also worth noting that SDL is also frequently used as a 2d API without any OpenGL functionality (I know of several indy games that do just that).

What would really be interesting is comparing how much work you would need to do in SDL to either get the same raw speed out of the 2d software API or produce the same results as you can get easily in SFML. Raw speed comparisons are rarely as useful as productivity comparisons due to moores law and other such technology trends increasing the base speed :)
Title: Benchmark : SDL vs SFML
Post by: Kernelpanic on May 17, 2008, 10:28:48 pm
Hey, how to compile this benchmark with g++/gcc?
I get only Compiler-Errors.
When I add #include s in main.cpp I can use some of the functions but not all of them.
Title: Benchmark : SDL vs SFML
Post by: Stonefish on September 10, 2008, 05:35:30 pm
I have made some optimization of SDL code by adding SDL_DisplayFormat() calls after image loading:
Quote

for( int i = 0; i < 5; ++i ) Images = SDL_DisplayFormat(Images);

After that I have very interesting results:
Quote

1/ Test : sprites
SDL  displayed 35 frames
SFML displayed 32 frames
--> SFML is 91% faster than SDL

2/ Test : alpha-blended sprites
SDL  displayed 25 frames
SFML displayed 31 frames
--> SFML is 124% faster than SDL

As you can see sprites drawing without alpha using SDL is faster then using SFML.
Title: Benchmark : SDL vs SFML
Post by: Wizzard on September 10, 2008, 07:12:58 pm
Quote from: "Stonefish"
As you can see sprites drawing without alpha using SDL is faster then using SFML.

This highly depends on the system you test with.
If you have a simply wonderful CPU and an utterly horrible GPU, SDL will likely run faster.
In general, computers, especially newer ones, should run SFML much faster than SDL.
However, I think this whole thing is rigged anyways.
SDL nor SFML should be judged based on their performance,
because they both support the use of OpenGL,
and everybody should be using OpenGL if their application needs performance.
Title: Benchmark : SDL vs SFML
Post by: Stonefish on September 11, 2008, 09:47:44 am
Quote from: "Wizzard"
This highly depends on the system you test with.


I think you don not understand me.
I simply wanted to say that your SDL test is not correct.
I perform the test with and without  SDL_DisplayFormat() on ONE computer. SDL test without SDL_DisplayFormat() was MUCH slower then SFML.

My hardware:
Quote

AMD Athlon X2 3800+  
GeForce 6100
Windows XP


As I see in SDL documentation SDL_DisplayFormat() is necessary to optimize bitmap blitting and that function call is recommended in all SDL tutorials.

I did not test sprite rotation and test drawing, but I think that sprite rotation will be slower in SDL even with my optimization because  SDL_gfx rotate image using CPU not GPU.

I like SFML more than SDL, but I think you have to change your SDL test code to show more truthful results.
Title: Benchmark : SDL vs SFML
Post by: Laurent on September 11, 2008, 10:09:00 am
You're right, the SDL results for static sprites are much better with this optimization (5x faster -- althought it's still 10x slower than SFML on my computer). For rotating sprites and text however it's not worth it (text doesn't even render at all).

But this benchmark is not only for comparing speed, it's also to compare programming interfaces; and I'm glad to see that SDL is even more complicated to use properly :mrgreen:
Title: Benchmark : SDL vs SFML
Post by: dunce on September 15, 2008, 05:58:25 am
Quote from: "Stonefish"
I have made some optimization of SDL code by adding SDL_DisplayFormat() calls after image loading:
Quote

for( int i = 0; i < 5; ++i ) Images = SDL_DisplayFormat(Images);

After that I have very interesting results:
Quote

1/ Test : sprites
SDL  displayed 35 frames
SFML displayed 32 frames
--> SFML is 91% faster than SDL

2/ Test : alpha-blended sprites
SDL  displayed 25 frames
SFML displayed 31 frames
--> SFML is 124% faster than SDL

As you can see sprites drawing without alpha using SDL is faster then using SFML.


91% and 124% both are wrong evaluations.

Correct evaluations should be:

1. delta = ((32 - 35) / 32) * 100; delta = -9.375%; SFML is slower.
2. delta = ((31 - 25) / 31) * 100; delta = 19.35%; SFML is faster.
Title: Benchmark : SDL vs SFML
Post by: eleinvisible on September 20, 2008, 01:34:03 am
Quote from: "Stonefish"

As you can see sprites drawing without alpha using SDL is faster then using SFML.
Ah yes... well, SFML doesn't use many OpenGL accelerations from what I have seen (or even DXT compression?), so such conclusions are premature considering SFML's age when compared to SDL.
Title: Benchmark : SDL vs SFML
Post by: heishe on September 22, 2008, 08:06:08 pm
you can still compare sdl to sfml. both are wrappers (sfml starting to lean towards the 2d engine area).

you could argue that sdl with opengl would at least be just as fast, but using sdl + opengl is nothing different from just using pure opengl. you just use sdl for creating the window and handling events anyways.

plus if you use sdl + opengl you don't automatically get this nice oop layout that sfml has.
Title: Benchmark : SDL vs SFML
Post by: Ceylo on September 22, 2008, 08:34:49 pm
Quote from: "heishe"
plus if you use sdl + opengl you don't automatically get this nice oop layout that sfml has.

How do you handle events with SDL and without a loop ?
Title: Benchmark : SDL vs SFML
Post by: zarka on September 22, 2008, 11:22:43 pm
Quote from: "Ceylo"
Quote from: "heishe"
plus if you use sdl + opengl you don't automatically get this nice oop layout that sfml has.

How do you handle events with SDL and without a loop ?


OOP (object oriented peogramming) not loop ;)
Title: Benchmark : SDL vs SFML
Post by: Ceylo on September 22, 2008, 11:50:14 pm
Quote from: "zarka"
OOP (object oriented peogramming) not loop ;)

Oh, k. Sorry :D .
Title: Benchmark : SDL vs SFML
Post by: ghiboz on November 13, 2008, 10:51:14 am
Hi, I have a question about your benchmark...
does anybody thest the differences using directly opengl and sfml?
actually my project is working on simple opengl.. and the features of sfml are very cool... I wish understand if the performances slow down using sfml or are pretty equals!

regards

ghiboz :wink:
Title: Benchmark : SDL vs SFML
Post by: Laurent on November 13, 2008, 11:26:46 am
It wouldn't make sense. SFML is using OpenGL, so any direct OpenGL code will be slightly faster than SFML (unless it's really not optimized), because SFML will always be more generic than your specific code, and genericity has a cost (less optimizations are possible).

Basically, the main goal of using raw OpenGL over SFML is to get better performances.
Title: Benchmark : SDL vs SFML
Post by: nitram_cero on November 18, 2008, 03:39:48 am
Quote
   SDL_Surface* App = SDL_SetVideoMode(800, 600, 32, SDL_SWSURFACE | SDL_DOUBLEBUF);


Maybe if you try with SDL_HWSURFACE (hardware) instead of SDL_SWSURFACE, it speeds things up.

Also, SDL_DisplayFormat is mandatory, or SDL will convert the bitmap on each blit, killing the framerate.

Regards
-Martín
Title: Benchmark : SDL vs SFML
Post by: Laurent on November 18, 2008, 07:55:29 am
Correct, I fixed it in a new version that I didn't upload.

Too bad SDL requires so much setup just to get things right ;)
Title: Benchmark : SDL vs SFML
Post by: Laurent on June 20, 2009, 11:56:03 am
Since this benchmark is still being criticized, I updated it to try making it as correct as possible.

The URL is still the same:
http://www.sfml-dev.org/temp/bench-sdl-sfml.zip
Title: Excellent Point
Post by: jmpeer on June 28, 2009, 07:44:43 pm
Quote from: "Hnefi"
Your benchmarks are severly flawed. You are comparing the software, 2D library that ships with SDL to OpenGL. Of course you are going to get a huge difference in performance - you don't even need to perform a benchmark to understand that.

What would be really interesting is to see how an SDL-driven OpenGL application performs compared to SFML. That would be a meaningful test, for two reasons: it compares similar technologies and it benchmarks against SDL the way SDL is almost always used.


After seeing SDL_DisplayFormat optimize its performance, I'm worried about these benchmarks. I support the development of SFML, but you should measure the true performance by fully optimizing both sides like this guy mentioned.
Title: Benchmark : SDL vs SFML
Post by: Laurent on June 28, 2009, 08:52:43 pm
No, I really want to compare SFML to the 2D API of SDL. Comparing SFML to OpenGL would be ridiculous, SFML is built on top of OpenGL and they have a very different purpose.

The graphics modules of SDL and SFML are supposed to be similar aren't they? So why shouldn't I compare them? Because SDL is too slow and unusable? Well, if I don't do this kind of benchmark, who will ever notice it?

Basically everyone here is just saying that SDL doesn't have a decent 2D module, and that's exactly one of the things I wanted to show (the other being the simplicity of the code -- if you want me to compare to OpenGL it will be even worse for SDL!).
Title: ^_^
Post by: jmpeer on June 28, 2009, 10:41:16 pm
Ah, I got you.
Seems pretty cool anyways, I'd like to learn it.
Title: Benchmark : SDL vs SFML
Post by: nitram_cero on July 06, 2009, 10:57:53 pm
SFML's interface API got me hooked away from SDL  :lol:

Non-OOP game ("media") libraries are a pain in the balls because you probably end up wrapping it in classes that are just like SFML  :P

Even thou I must accept is a whole lot easier and faster to work on pixels in software mode. Reloading a whole texture for just a couple of pixels each frame is slower I believe.

But well, SDL was created a long time ago. It has gained it deserved popularity... but I think it's time to move on.

I mean, people are still using allegro. I used to read about allegro when I was a kid on game magazines... back then it was the shit (as in awesome).
From wikipedia:
Quote
Initially standing for "Atari Low-Level Game Routines"...for the Atari ST in the early 1990s.

ATARI, DUDE xD

Well, I think the best propaganda for developers is the one that compares numbers. Geez, If a politician showed me some numbers instead of sensless babling... he'd win my vote  :lol:

I will check the benchmark when I have some time.

Regards
-Martín
Title: Benchmark : SDL vs SFML
Post by: Jonny D on October 15, 2009, 09:43:15 pm
I took a stab at it on a 2nd gen Macbook running Debian.  There was only one build error: EXIT_SUCCESS is not defined in main.cpp.

I made a couple of changes and added two tests.  You only tested per-surface alpha-blending, so I added a test for per-pixel alpha (it uses SDL_image now).  You also made a couple of no-no's in the rotation and dynamic text tests by creating surfaces within the loop (allocating and freeing tons of memory per second).  I changed the rotation test to use SGE's direct rotations (and made it work correctly) and I plugged in NFont so that I could cache the font, rather than generate each glyph when needed.  These represent more truly the way that people actually use SDL and its supporting libs for speed.  So, Test 2 is not very indicative of typical usage, and Test 6 should be thrown right out.  One note: Test 7 uses only Normal font style, since NFont doesn't load the character width correctly for others.

You can get my version at http://code.bluedinosaurs.com/SDL/bench-sdl-sfml-j.zip

The results are not that amazing.  I'd like to see the results from other computers.  Also, if you mean this thread to tell beginners about the speed differences between SDL and SFML, then you need to be upfront about it.  The first results don't seem to be updated and you don't mention exactly what you're testing (software SDL vs hardware SFML) until a later page.  In the head post, it should state that SDL can be used to make hardware-accelerated graphics, but SDL's built-in 2d support, which is being tested, is in software, whereas SFML uses hardware acceleration.  Indeed, SDL 1.3 (as opposed to SDL 1.2 used in this benchmark) uses hardware acceleration on its 2d graphics, just like SFML.

My results:

1/ Test : sprites
SDL  displayed 47 frames
SFML displayed 51 frames
--> SFML is 1.09x as fast as SDL

2/ Test : alpha-blended sprites
SDL  displayed 38 frames
SFML displayed 52 frames
--> SFML is 1.37x as fast as SDL

3/ Test : per-pixel alpha-blended sprites
SDL  displayed 42 frames
SFML displayed 47 frames
--> SFML is 1.12x as fast as SDL

4/ Test : rotating sprites
SDL  displayed 26 frames
SFML displayed 26 frames
--> SFML is 1.00x as fast as SDL

5/ Test : static text
SDL  displayed 1382 frames
SFML displayed 1023 frames
--> SFML is 0.74x as fast as SDL

6/ Test : dynamic text
SDL  displayed 194 frames
SFML displayed 727 frames
--> SFML is 3.75x as fast as SDL

7/ Test : dynamic text w/NFont
SDL  displayed 779 frames
SFML displayed 1113 frames
--> SFML is 1.43x as fast as SDL
Title: Benchmark : SDL vs SFML
Post by: Laurent on October 15, 2009, 10:18:23 pm
I'm glad to see someone providing a really optimized SDL code, thanks.

First, this topic is not about the speed difference between SDL and SFML. It's about speed & easiness. The only thing that I want to show is that you can get both of them with SFML, not with SDL. You can get a code as simple as SFML (this is my first version of the benchmark) but with poor performances, or you can get a code almost as fast as SFML but with tons of addons and tweaks (this is your version).

That's all I want to show, and so far it still works :)

Quote
you don't mention exactly what you're testing (software SDL vs hardware SFML)

I'm testing SDL and SFML. Hardware / software is just an implementation detail.
Moreover, does hardware SDL exist? SDL 1.3 is still in progress, and SDL + OpenGL... well it's OpenGL, not SDL.

Quote
Indeed, SDL 1.3 (as opposed to SDL 1.2 used in this benchmark) uses hardware acceleration on its 2d graphics, just like SFML.

I already had a look at SDL 1.3, but was too lazy to try figuring out how it works (I mean, the public API). I'm really curious to see it in action :)
Title: Benchmark : SDL vs SFML
Post by: Jonny D on October 16, 2009, 12:04:08 am
Quote from: "Laurent"
First, this topic is not about the speed difference between SDL and SFML. It's about speed & easiness. The only thing that I want to show is that you can get both of them with SFML, not with SDL.


Agreed :)
Us with a mind towards C++ do need to wrap SDL a bit to get comfortable.

Quote
You can get a code as simple as SFML (this is my first version of the benchmark) but with poor performances, or you can get a code almost as fast as SFML but with tons of addons and tweaks (this is your version).


I don't think this is quite true.  There is a big difference between SDL and SFML in that SDL covers the crossplatform basics and you choose libraries for your task (the "pick-and-choose" approach), whereas SFML wraps and makes available everything you might need (the "one-stop-shop" approach).  It's really up to the user to decide what is best for him/her.  For beginners, the latter approach is clearly better, in my opinion.  It is nice to have a consistent interface, but I prefer using several small libraries with maintainers who can optimize each one well.  I didn't tweak anything for the tests, but I did use the extension libraries the way they're meant to be used.  You are an expert with SFML, so I thought SDL needed someone with experience to make the benchmark more viable.

Quote
I'm testing SDL and SFML. Hardware / software is just an implementation detail.


It's not just an implementation detail.  It means real things on various platforms.  If you're on an embedded system with no GPU, then SDL and other software-optimized libraries are much, much faster than a software OpenGL implementation.

Quote
Moreover, does hardware SDL exist? SDL 1.3 is still in progress, and SDL + OpenGL... well it's OpenGL, not SDL.


Yes, hardware SDL exists.  In its original form, you've been using it by using SDL_HWSURFACE (i.e. requesting a surface in video memory).  In a form more comparable to SFML, you would either use glSDL or SDL 1.3.  glSDL is a replacement of the SDL backend with an OpenGL one.  A similar, but not identical, idea is what has become SDL 1.3.

Quote
I already had a look at SDL 1.3, but was too lazy to try figuring out how it works (I mean, the public API). I'm really curious to see it in action :)


Yeah, who knows when an official release will occur...  I look forward most to the multiple mice/keyboard/monitor/window stuff.
Title: Benchmark : SDL vs SFML
Post by: Laurent on October 16, 2009, 10:18:21 am
Quote
There is a big difference between SDL and SFML in that SDL covers the crossplatform basics and you choose libraries for your task (the "pick-and-choose" approach), whereas SFML wraps and makes available everything you might need (the "one-stop-shop" approach)

This is not 100% true. SFML is divided into 5 different modules as well, and you can pick only what you need.
The thing with SDL is that the different modules are not consistent, there's no common base (unlike SFML). SDL, SDL_net, SDL_image, NFont, SGE, ... it looks like you need to gather a lot of different libraries, rather than using different modules of the same thing. It's confusing for beginners. And you don't easily find documentation for some modules (yesterday I was unable to find a reference for the sge_transform function that you use). Plus, I think that there are slightly too many modules; SDL_image is a good example: I think it is stupid to have to use a separate library just to be able to handle the most common image formats.

Quote
You are an expert with SFML, so I thought SDL needed someone with experience to make the benchmark more viable

Absolutely!

Quote
It's not just an implementation detail. It means real things on various platforms. If you're on an embedded system with no GPU, then SDL and other software-optimized libraries are much, much faster than a software OpenGL implementation.

But I'm not talking about such systems, SFML is only made for desktop PCs (for now). And people using a graphics library don't care about the internals of this library, they just want it to have good performances, whether it is hardware accelerated or not. Especially beginners, who know nothing about hardware / software and OpenGL stuff.

Quote
Yes, hardware SDL exists. In its original form, you've been using it by using SDL_HWSURFACE (i.e. requesting a surface in video memory)

So I'm indeed comparing hardware SDL to hardware SFML ;)

Quote
glSDL is a replacement of the SDL backend with an OpenGL one

But it's not SDL. This is another example where you need another separate library to get something interesting from SDL.

Quote
A similar, but not identical, idea is what has become SDL 1.3.

I think I'll try to dive into the internals of SDL 1.3 and see how they render 2D stuff using OpenGL. It should be interesting :)
Title: Benchmark : SDL vs SFML
Post by: richardwb on January 11, 2010, 08:23:46 am
I spent a bit of time and gathered the necessary libraries (it took some time) to provide an additional data point for this benchmark. I used Jonny D's version of the benchmark. This is on a Core 2 Quad @ 3.0GHz, 8GB RAM, Nvidia 8800GT under Vista 64-bit and Visual Studio 2008.

There were some visual inconsistencies in the dynamic text benchmark.

Code: [Select]
1/ Test : sprites
SDL  displayed 168 frames
SFML displayed 736 frames
--> SFML is 4.38x as fast as SDL

2/ Test : alpha-blended sprites
SDL  displayed 12 frames
SFML displayed 505 frames
--> SFML is 42.08x as fast as SDL

3/ Test : per-pixel alpha-blended sprites
SDL  displayed 16 frames
SFML displayed 709 frames
--> SFML is 44.31x as fast as SDL

4/ Test : rotating sprites
SDL  displayed 30 frames
SFML displayed 691 frames
--> SFML is 23.03x as fast as SDL

5/ Test : static text
SDL  displayed 756 frames
SFML displayed 7273 frames
--> SFML is 9.62x as fast as SDL

6/ Test : dynamic text
SDL  displayed 116 frames
SFML displayed 3697 frames
--> SFML is 31.87x as fast as SDL

7/ Test : dynamic text w/NFont
SDL  displayed 606 frames
SFML displayed 4575 frames
--> SFML is 7.55x as fast as SDL
Title: Benchmark : SDL vs SFML
Post by: solgar on January 11, 2010, 09:37:26 am
Testing machine: some HP Pavilion dv7.
Result:

Code: [Select]
1/ Test : sprites
SDL  displayed 51 frames
SFML displayed 69 frames
--> SFML is 1.4x as fast as SDL

2/ Test : alpha-blended sprites
SDL  displayed 24 frames
SFML displayed 69 frames
--> SFML is 2.9x as fast as SDL

3/ Test : rotating sprites
SDL  displayed 14 frames
SFML displayed 71 frames
--> SFML is 5.1x as fast as SDL

4/ Test : static text
SDL  displayed 804 frames
SFML displayed 2566 frames
--> SFML is 3.2x as fast as SDL

5/ Test : dynamic text
SDL  displayed 119 frames
SFML displayed 2300 frames
--> SFML is 19.3x as fast as SDL


Test from http://www.sfml-dev.org/temp/bench-sdl-sfml.zip
Title: Benchmark : SDL vs SFML
Post by: insa on January 11, 2010, 01:46:41 pm
Testing Machine: lenovo S10e (Intel Atom N270 @ 1.60GHz, 2GB RAM), Win7

Code: [Select]
1/ Test : sprites
SDL  displayed 27 frames
SFML displayed 48 frames
--> SFML is 1.8x as fast as SDL

2/ Test : alpha-blended sprites
SDL  displayed 12 frames
SFML displayed 53 frames
--> SFML is 4.4x as fast as SDL

3/ Test : rotating sprites
SDL  displayed 6 frames
SFML displayed 51 frames
--> SFML is 8.5x as fast as SDL

4/ Test : static text
SDL  displayed 479 frames
SFML displayed 1110 frames
--> SFML is 2.3x as fast as SDL

5/ Test : dynamic text
SDL  displayed 33 frames
SFML displayed 464 frames
--> SFML is 14.1x as fast as SDL
Title: Benchmark : SDL vs SFML
Post by: nullsquared on January 11, 2010, 09:29:43 pm
I don't understand the point of this test.

It's like testing a software renderer vs. Direct3D and concluding that Direct3D is faster.
Title: Benchmark : SDL vs SFML
Post by: K-Bal on January 11, 2010, 11:03:26 pm
Quote from: "nullsquared"
I don't understand the point of this test.

It's like testing a software renderer vs. Direct3D and concluding that Direct3D is faster.


An obvious conclusion, but some people don't know about this. So what's wrong with it?
Title: Benchmark : SDL vs SFML
Post by: nullsquared on January 11, 2010, 11:09:51 pm
Quote from: "K-Bal"


An obvious conclusion, but some people don't know about this. So what's wrong with it?

What's wrong with it?  Exactly what I pointed out.

Same thing as comparing a Nissan Quest to a Lamborghini Gallardo and concluding that the Gallardo is faster.
Title: Benchmark : SDL vs SFML
Post by: Laurent on January 12, 2010, 12:08:34 am
Oh please, don't do it again...

Ok, I'll try to make it simple. SDL and SFML have similar 2D APIs, right? So why the hell shouldn't they be compared? It's up to SDL if it's not implemented with the fastest low-level API available. Do beginners care about whether their 2D library uses OpenGL or not? They just want it to be fast, they don't know what OpenGL is.

And when SDL 1.3 is released with its OpenGL backend, this benchmark will suddenly make sense? Oh no wait, it will have a Direct3D backend as well, so it cannot be compared against SFML, this is not fair.

And what about a library that would not be open-source? It couldn't be compared to anything because we don't know what backend it uses? ...

Sorry for being sarcastic, but everyone says that SDL cannot be as fast as SFML; I'm just demonstrating it with numbers, because this is not obvious for everyone on earth.
In my opinion they are two similar APIs and it would not be fair not to compare them.
Title: Benchmark : SDL vs SFML
Post by: OniLinkPlus on January 12, 2010, 01:58:32 am
Quote from: "nullsquared"
I don't understand the point of this test.

It's like testing a software renderer vs. Direct3D and concluding that Direct3D is faster.
Except it uses hardware accelerated SDL(through Direct3D)  and hardware accelerated SFML(through OpenGL).
Title: Benchmark : SDL vs SFML
Post by: nullsquared on January 12, 2010, 03:24:03 am
SDL isn't meant for computers with hardcore graphics accelerators (AKA modern GPUs).

Just like a Nissan Quest is a family car, not a sports car for some rich guy.

SFML is meant for computers with decent if not hardcore GPUs.

Just like a Lamborghini Gallardo.

Yes, the noob will take a look at both cars and say, "of course I want the Gallardo, it's so much faster and cooler looking!"

That doesn't mean the Nissan Quest is now useless, which is essentially what you're trying to show in this benchmark.
Title: Benchmark : SDL vs SFML
Post by: Laurent on January 12, 2010, 08:30:47 am
Quote
SDL isn't meant for computers with hardcore graphics accelerators (AKA modern GPUs).

That's a tough statement. Basically, you're saying that SDL is deprecated for desktop computers, which represents a vast majority of users now. I wouldn't say that...

Quote
SFML is meant for computers with decent if not hardcore GPUs.

Well, it can also run fine with OpenGL 1.1 crappy drivers, like the Intel GPUs we can find on old laptops. I don't call that "hardcore". And I'm sure that I can find a software OpenGL implementation that can run without a GPU. That's the beauty of using a standard and widely implemented graphics API.

Quote
Yes, the noob will take a look at both cars and say, "of course I want the Gallardo, it's so much faster and cooler looking!"

How can he tell if there's no benchmark at all? People shouldn't have to look into internal details and document themselves about low-level technologies in order to know which one is faster.

Quote
That doesn't mean the Nissan Quest is now useless, which is essentially what you're trying to show in this benchmark.

Absolutely not. I'm just showing that SFML is better when we compare both easiness and performances of the 2D API together. SDL can have the same API but with bad performances, or it can get the same performances but with additional tweaking or even other thrid-party libraries.
And believe me or not, but I don't like this benchmark. I did it to make people happy, I had tons of users who wanted such a benchmark.
Title: Benchmark : SDL vs SFML
Post by: T.T.H. on January 13, 2010, 11:17:43 am
When you ask the internet for a 2D graphic library ("car") the internet usually points you on SDL ("Nissan"). Next to some other interesting 2D libraries some clever people will even point you on SFML ("Lamborghini").

Yes, SDL in it's most basic form is a software-renderer and SFML is a hardware-accelerated-renderer and, yes, the hardware requirements of SDL are insanely low (code for your fridge) while those of SFML seem to be pretty low (code for your laptop).

But, and that is my personal uber-mega-super-power-argument-but, when you enter the SDL Nissan, you'll find out that the wheels are not completely round, that the steering wheel goes strong, that the security belts are week, that the gas it needs is antique, that features like lights, windscreen wiper, heating and radio are extras you have to buy and install yourself and that the final driving experience absolutely and totally feels like a fight against the car itself.

On the other hand, when you enter the SFML Lamborghini and do have some rogue experience with cars already you'll find out that all the controls and the steering feel familiar, that all basics and most uncommon extras and even some fancy gadgets are already included, that the gas tank is full and when you start the engine and push the pedal you'll race off like a sports car and will immediately have fun while driving.
Title: Benchmark : SDL vs SFML
Post by: nullsquared on January 13, 2010, 12:59:47 pm
Quote from: "T.T.H."

But, and that is my personal uber-mega-super-power-argument-but, when you enter the SDL Nissan, you'll find out that the wheels are not completely round, that the steering wheel goes strong, that the security belts are week, that the gas it needs is antique, that features like lights, windscreen wiper, heating and radio are extras you have to buy and install yourself and that the final driving experience absolutely and totally feels like a fight against the car itself.


Your SFML metaphor sounds correct but your SDL one does not.  It seems that the driver is someone who has never stepped in the driver's seat of a car ever before and simply does not know what to expect.

SDL may be slower than SFML (moot argument for reasons I've previously pointed out), but it is definitely not a fight against itself - it has its uses.
Title: Benchmark : SDL vs SFML
Post by: panithadrum on January 13, 2010, 09:20:00 pm
God, you are driving me crazy with cars, lamborginis, nissans and shit lol.

SFML is faster than SDL, so this benchmark proves that. I don't care about software or hardware. It's just SFML > SDL. No more.
Title: Benchmark : SDL vs SFML
Post by: hacky on January 16, 2010, 08:37:36 pm
Quote
SFML is faster than SDL, so this benchmark proves that. I don't care about software or hardware. It's just SFML > SDL. No more.

this.
Title: Benchmark : SDL vs SFML
Post by: T.T.H. on January 18, 2010, 10:57:36 am
Quote from: "nullsquared"
Your SFML metaphor sounds correct but your SDL one does not.  It seems that the driver is someone who has never stepped in the driver's seat of a car ever before and simply does not know what to expect.

SDL was the second 2D engine I ever used (after some simple sprite blitting based on DirectX5/DirectX7) and for me it felt "awkward" to work with. When I found SFML and tried the very same things with it everything felt "intuitive" for me.

In SDL I spent time with getting the surfaces allocated in the correct color format and getting some sprites rotated. In SFML those things did cost me minutes and I spend less time with the graphic basics and more time with my game logic.

Indeed this all is a very personal and subjective experience but as the leap had been so huge for me I keep telling my story. I strongly believe that for a beginner who wants to make something 2D based in C++ for a modern platform like a desktop or laptop PC SFML is a far, far better choice than SDL .

Regarding speed (FPS) the hardware-accelerated SFML is obviously faster than the software-rendered SDL. I think it is superfluous to argue that one is better than the other due to the speed argument.

In addition SDL does loose even more appeal in my eyes after reading that there will be a commerial license (http://www.galaxygameworks.com/index.html) for it (with all the cool features of course like e.x. statically linking). Nothing against paying good money for good software but in my case I can get all I want (usability, speed, coding for the laptop, not coding for the fridge = SFML) for free (SFML's zlib/png license).
Title: Benchmark : SDL vs SFML
Post by: nachy on March 28, 2010, 05:26:51 am
Quote from: "T.T.H."
In addition SDL does loose even more appeal in my eyes after reading that there will be a commerial license for it (with all the cool features of course like e.x. statically linking). Nothing against paying good money for good software but in my case I can get all I want (usability, speed, coding for the laptop, not coding for the fridge = SFML) for free (SFML's zlib/png license).

This is exactly the reason why I chose SFML now. Not any performance difference, nor OOP aspect. Only the license.
For me SDL used to be THE free lib for platform independent graphic stuff even if it never was with it's gpl license but this step towards adding a commercial license killed it for me. Their comparison chart alone is so yuck.
I guess it's ok if you actually want to use it commercially or want to bother with the GPL but I've come to the conclusion that I want to bother with licenses the least possible with my small projects and the zlib/png one is perfect for that.

I'm sure you can also code fast software with SDL if you tweak things, use HW rendering, OpenGL and so on. The tests were supposed to show a difference with "default settings" though I think. Like if you're new to both libs and write your first application. Some people are taking it too serious.

On a side note this little application I have seems to be running faster with still-WIP-SFML2 than it did with SFML1.5. So either it's just something related to my application or SFML will have some performance gain once version 2 is a stable release  :)
Title: Benchmark : SDL vs SFML
Post by: Ashenwraith on April 13, 2010, 05:05:49 pm
This thread is smart and a good idea.

Benchmarking SFML against SDL should be standardized with each major release of SFML--or at least the benchmark executable updated.

BTW, I found SFML by searching "better than SDL" and "SDL sucks"  8)
Title: Benchmark : SDL vs SFML
Post by: Spodi on April 13, 2010, 07:03:23 pm
As long as SFML is "around SDL" in terms of performance, anything more is just a bonus to me. I use SFML for its design, very active development, and great 2d support. Any speed improvements are just a bonus. How many of you are actually 1) hitting a frame rate limit, 2) have a reasonable amount of rendering being done, and 3) have already optimized your rendering? There is a huge amount of stuff you can do to optimize rendering on the user side. From what I can see, SFML is pretty much bottlenecked by the drawing calls, which is usually what happens with most 2d engines. So there likely isn't a whole lot SFML can do besides batching, but even then I have had mixed results when it comes to that since batching in 2d isn't always so beneficial.

Focus on designing your game. If by the time you finish, and your game isn't running fast enough, optimize the way you are rendering and add some support for toggling effects/quality. If that still isn't enough, then you can consider SFML's performance. Until then, its just "an interesting statistic".
Title: Benchmark : SDL vs SFML
Post by: Ashenwraith on April 13, 2010, 07:25:13 pm
Quote from: "Spodi"
As long as SFML is "around SDL" in terms of performance, anything more is just a bonus to me. I use SFML for its design, very active development, and great 2d support. Any speed improvements are just a bonus. How many of you are actually 1) hitting a frame rate limit, 2) have a reasonable amount of rendering being done, and 3) have already optimized your rendering? There is a huge amount of stuff you can do to optimize rendering on the user side. From what I can see, SFML is pretty much bottlenecked by the drawing calls, which is usually what happens with most 2d engines. So there likely isn't a whole lot SFML can do besides batching, but even then I have had mixed results when it comes to that since batching in 2d isn't always so beneficial.

Focus on designing your game. If by the time you finish, and your game isn't running fast enough, optimize the way you are rendering and add some support for toggling effects/quality. If that still isn't enough, then you can consider SFML's performance. Until then, its just "an interesting statistic".


Speaking of performance, how is xna/directx working for 2d?
Title: Benchmark : SDL vs SFML
Post by: Spodi on April 14, 2010, 02:57:39 am
Quote from: "Ashenwraith"

Speaking of performance, how is xna/directx working for 2d?


Xna actually has surprisingly great support for 2D. Its not as simple as SFML, but one big thing they have going for them is their SpriteBatch class. There are 5 sorting methods:
1. Immediate: Draw whenever the state (texture) changes.
2. Texture: Draw everything at once, ordered by texture (for when stuff doesn't overlap).
3. Deferred: Draw all at once in the same order called (same as Immediate, but delayed, I believe - its so you can build up multiple batches at once without messing up the drawing).
4. Front-to-back: Deferred, but sorted by depth.
5. Back-to-front: Deferred, but sorted by depth (other direction).

I personally only really used Immediate, since I find it easy enough to handle the ordering myself. I assume this is pretty much like the batching Laurent added to SFML 2.0. If a call to draw uses the same state as the last call, you queue it into the batch. If the state changes, you flush the queue, clear it, then place the newest call in the front of the batch. Combined with texture atlases, I was able to render my whole scenes in under 30-or-so batches.

However, with XNA, you are in a load of hurt if you try to do things your own way. One reason I switch from XNA to SFML for my project was since I didn't like how XNA's ContentManager worked. Switching to SFML, I had a robust content manager that supports lazy-loading, only loading one instance of each asset, and automatic asset reloading (if you call an asset that has been disposed, it reloads from file transparently) done very quickly. Trying to do this with XNA, I gave up after about a full day of working on it, and tons of hacking with reflection.

In my project, since I just replaced XNA with SFML, things are being used pretty much the same way. From what I can see, the only real performance hits are coming from the fact that I no longer have any batching. But even still, I am hitting 60 FPS no sweat. I think the SFML version is running about 50%* slower while doing the exact same stuff (even using texture atlases still), but again, we're comparing no batching to batching, and I am still using SFML 1.5. And my rendering is still written with XNA in mind, not SFML.

*This is a complete guess from memory based purely on approximate numbers I remember when looking at the Task Manager. In no way have I EVER actually measured it.

As far as simplicity goes, SFML beats XNA hands-down for 2D. Its quite scary how simple SFML is. And at least when you don't like how something works in SFML, you can roll your own without a fight.
Title: Benchmark : SDL vs SFML
Post by: Osbios on April 14, 2010, 02:01:45 pm
Well SDL is nice for software rendering. Like a raytracer or real old style 320x200 pixel games. And at the begining I belived it would also make a good basic opengl context.
But after trying some time I just good feedup with all the bugs that I found in basic usage. For example you get the mouse at a totaly wrong position if you catch it in the opengl window. Or there is a missing event in some circumstances if you resize the window... and may some more...

So for me the most importend fact is, there is no real development going on anymore for SDL. Or at last not enough for my taste... so this bugs wont be fixed anytime soon.

Thats the point where SFML looks very different.
Title: Benchmark : SDL vs SFML
Post by: Ashenwraith on April 14, 2010, 03:31:01 pm
Quote from: "Spodi"
Quote from: "Ashenwraith"

Speaking of performance, how is xna/directx working for 2d?


Xna actually has surprisingly great support for 2D. Its not as simple as SFML, but one big thing they have going for them is their SpriteBatch class. There are 5 sorting methods:
1. Immediate: Draw whenever the state (texture) changes.
2. Texture: Draw everything at once, ordered by texture (for when stuff doesn't overlap).
3. Deferred: Draw all at once in the same order called (same as Immediate, but delayed, I believe - its so you can build up multiple batches at once without messing up the drawing).
4. Front-to-back: Deferred, but sorted by depth.
5. Back-to-front: Deferred, but sorted by depth (other direction).

I personally only really used Immediate, since I find it easy enough to handle the ordering myself. I assume this is pretty much like the batching Laurent added to SFML 2.0. If a call to draw uses the same state as the last call, you queue it into the batch. If the state changes, you flush the queue, clear it, then place the newest call in the front of the batch. Combined with texture atlases, I was able to render my whole scenes in under 30-or-so batches.

However, with XNA, you are in a load of hurt if you try to do things your own way. One reason I switch from XNA to SFML for my project was since I didn't like how XNA's ContentManager worked. Switching to SFML, I had a robust content manager that supports lazy-loading, only loading one instance of each asset, and automatic asset reloading (if you call an asset that has been disposed, it reloads from file transparently) done very quickly. Trying to do this with XNA, I gave up after about a full day of working on it, and tons of hacking with reflection.

In my project, since I just replaced XNA with SFML, things are being used pretty much the same way. From what I can see, the only real performance hits are coming from the fact that I no longer have any batching. But even still, I am hitting 60 FPS no sweat. I think the SFML version is running about 50%* slower while doing the exact same stuff (even using texture atlases still), but again, we're comparing no batching to batching, and I am still using SFML 1.5. And my rendering is still written with XNA in mind, not SFML.

*This is a complete guess from memory based purely on approximate numbers I remember when looking at the Task Manager. In no way have I EVER actually measured it.

As far as simplicity goes, SFML beats XNA hands-down for 2D. Its quite scary how simple SFML is. And at least when you don't like how something works in SFML, you can roll your own without a fight.


Would be nice to see some benchmarks of XNA vs SFML 2

So are you giving up on XNA?

I thought  an XNA port of SFML would be cool.
Title: Benchmark : SDL vs SFML
Post by: Spodi on April 14, 2010, 05:49:37 pm
Yeah, I gave up on XNA after using it for about 2 years. I like SFML a lot more for 2d.
Title: Benchmark : SDL vs SFML
Post by: Ceylo on April 14, 2010, 05:57:39 pm
Quote from: "Ashenwraith"
I thought  an XNA port of SFML would be cool.

I don't think "cool" is good reason for Laurent to implement a XNA backend  :lol: . Moreover it'd be a huge work, it's not portable, and benefits still need to be demonstrated. Thus Laurent might keep using OpenGL :P .
Title: Benchmark : SDL vs SFML
Post by: Ashenwraith on April 14, 2010, 06:46:44 pm
Quote from: "Ceylo"
Quote from: "Ashenwraith"
I thought  an XNA port of SFML would be cool.

I don't think "cool" is good reason for Laurent to implement a XNA backend  :lol: . Moreover it'd be a huge work, it's not portable, and benefits still need to be demonstrated. Thus Laurent might keep using OpenGL :P .


I wasn't proposing Laurent make an XNA backend, but as for the benefits--XNA seems to be the most open and easy way to get a game onto the xbox360.

Xbox Live! has a large 2D fanbase where many people actually still purchase 2D games (even retro ones). PSN's markeshare doesn't even compare. You have to go to handhelds for the next biggest market and good luck breaking into that.

http://www.gamasutra.com/view/news/28075/InDepth_Xbox_Live_Arcade_Sales_Analysis_March_2010.php
Title: Benchmark : SDL vs SFML
Post by: Ceylo on April 14, 2010, 06:57:42 pm
Quote from: "Ashenwraith"
I wasn't proposing Laurent make an XNA backend, [...]

So what do you mean with "porting SFML to XNA" ? Making a new version SFML targetting Xbox 360 ? (like what may be done for an iPhone port ?)
Title: Benchmark : SDL vs SFML
Post by: Ceylo on April 14, 2010, 07:00:23 pm
As for the benefits, I was rather thinking of the benefits of using XNA, not of making a port for Xbox 360, even if both are linked. So.. ok as far as the benefits of a Xbox 360 port, even if I don't know whether it's achievable.
Title: Benchmark : SDL vs SFML
Post by: Ashenwraith on April 14, 2010, 07:20:53 pm
Quote from: "Ceylo"
As for the benefits, I was rather thinking of the benefits of using XNA, not of making a port for Xbox 360, even if both are linked. So.. ok as far as the benefits of a Xbox 360 port, even if I don't know whether it's achievable.


Yeah, I prefer OpenGL/C++ over DirextX and C#, but I know XNA is integrated with Visual Studio.NET so I don't know if that helps.

But as for the benefit of XNA is summed up as:

"XNA Indie Games

Xbox 360 games written in XNA Game Studio can be submitted to the Creators Club community, for which premium membership is required, this costs US$49 for 4 months or US$99/year. All games submitted to the community are subjected to peer review by other creators. If the game passes review then it is listed on Xbox Live Marketplace. Creators can set a price of 80, 240 or 400 points for their game. The creator is paid 70% of the total revenue from their game sales as a baseline."
Title: Benchmark : SDL vs SFML
Post by: xazax on March 20, 2011, 11:56:59 am
A similar benchmark between sfml2 and sfml1.6 would be very interesting :)
Title: Benchmark : SDL vs SFML
Post by: thoralmighty on July 06, 2011, 10:51:58 pm
Quote from: "xazax"
A similar benchmark between sfml2 and sfml1.6 would be very interesting :)

interesting idea
Title: Bump
Post by: asdatapel on September 07, 2011, 04:40:06 am
Im gonna bump this topic cuz Id like to see how the results have changed after three years. Can you run the test again?
Title: Benchmark : SDL vs SFML
Post by: Hiura on September 07, 2011, 09:17:18 am
Not now because Laurent is planning to modify the graphics API. So maybe in a few weeks.  :wink:
Title: Benchmark : SDL vs SFML
Post by: Groogy on September 07, 2011, 10:04:59 am
Actually, see a benchmark after the graphics api change both between SFML2 vs SFML2(before and after change) and between SFML2 and SFML1.6 and SFML2 and SDL or any other API we can find ^^
Title: Re: Benchmark : SDL vs SFML
Post by: AdelR on August 18, 2012, 01:48:10 am
Now that SFML 2.0 and SDL 1.3 APIs have stabilized it would be interesting to see new benchmark.
Title: Re: Benchmark : SDL vs SFML
Post by: eXpl0it3r on August 18, 2012, 05:42:19 pm
Now that SFML 2.0 and SDL 1.3 APIs have stabilized it would be interesting to see new benchmark.
You like to play with fire bumping a nearly one year old thread as your second post, but fear not, as the SFML community doesn't forbid this. ;D

Actually I've always wanted to recreate that benchmark but never gotten around until you reminded me today and so I took my time and converted everything to SFML 2 (which was very very easy) and then compiled all the stuff (SDL, SDL_ttf, SGE) needed for the SDL (which was kind of a pain).

So here we go with my results with the latest SFML (https://github.com/SFML/SFML/tree/abd842510efaa2816b2f2e7348426163c57058c5) version, the SDL 1.2 (http://www.libsdl.org/hg.php) library (changeset: 6396:b1c1b7ac4b39), the latest SDL_tff library (http://www.libsdl.org/projects/SDL_ttf/) (version 2.0.11) and the latest SGE library (http://www.digitalfanatics.org/cal/sge/) r030809. Everything linked dynamically and run in release mode:
1/ Test : sprites
SDL  displayed 388 frames
SFML displayed 147 frames
--> SFML is 0.4x as fast as SDL

2/ Test : alpha-blended sprites
SDL  displayed 107 frames
SFML displayed 146 frames
--> SFML is 1.4x as fast as SDL

3/ Test : rotating sprites
SDL  displayed 14 frames
SFML displayed 150 frames
--> SFML is 10.7x as fast as SDL

4/ Test : static text
SDL  displayed 3434 frames
SFML displayed 6187 frames
--> SFML is 1.8x as fast as SDL

5/ Test : dynamic text
SDL  displayed 155 frames
SFML displayed 4479 frames
--> SFML is 28.9x as fast as SDL
It's interesting to see SDL beating SFML in the static sprite rendering whereas in 2007 it was bearly able to draw a few frames. ;)
But the static rendering is also already the only part where SDL is a tick faster then SFML.

If you want to try it or add anything, I've setup a Git(Hub) repository (I hope Laurent doesn't mind) so you can get the code + resources from here (https://github.com/eXpl0it3r/SFML-vs-SDL-Benchmark) and for a fully working demo for Windows 32bit you can get the executable, libraries, resources and source from here (https://github.com/downloads/eXpl0it3r/SFML-vs-SDL-Benchmark/Benchmark.zip).

I hope to see some further benchmarks since it can vary largly from hardware to hardware. :)
I personally would be interested in a pixel manipulation comparison and a SFML 2 vs SDL 2, so if anyone got a bit time and knowledge... :D
Title: Re: Benchmark : SDL vs SFML
Post by: AdelR on August 19, 2012, 03:09:55 am
Thanks for building new benchmark.

First thing i noticed thou was that program won't start as it lacks libfreetype-6.dll and zlib1.dll. After finding latest versions of them the bench started.

My computer is i5-2500k, 8gb of RAM and GeForce GTX 570, no overcloking. Results were in range, except one unexpected:

1/ Test : sprites
SDL  displayed 384 frames
SFML displayed 301 frames
--> SFML is 0.8x as fast as SDL

2/ Test : alpha-blended sprites
SDL  displayed 102 frames
SFML displayed 301 frames
--> SFML is 3.0x as fast as SDL

3/ Test : rotating sprites
SDL  displayed 63 frames
SFML displayed 301 frames
--> SFML is 4.8x as fast as SDL

4/ Test : static text
SDL  displayed 3484 frames
SFML displayed 302 frames
--> SFML is 0.1x as fast as SDL

5/ Test : dynamic text
SDL  displayed 138 frames
SFML displayed 302 frames
--> SFML is 2.2x as fast as SDL

Title: Re: Benchmark : SDL vs SFML
Post by: victorlevasseur on August 19, 2012, 09:49:24 am
Do you limit framerate or activate V-sync, because the amount of frames is similar for each tests (301 or 302) ?
Title: Re: Benchmark : SDL vs SFML
Post by: AdelR on August 19, 2012, 11:54:19 am
Yeah, totaly forgot. Set global V-sync not long ago.

1/ Test : sprites
SDL  displayed 428 frames
SFML displayed 1481 frames
--> SFML is 3.5x as fast as SDL

2/ Test : alpha-blended sprites
SDL  displayed 114 frames
SFML displayed 1504 frames
--> SFML is 13.2x as fast as SDL

3/ Test : rotating sprites
SDL  displayed 67 frames
SFML displayed 1502 frames
--> SFML is 22.4x as fast as SDL

4/ Test : static text
SDL  displayed 3648 frames
SFML displayed 27344 frames
--> SFML is 7.5x as fast as SDL

5/ Test : dynamic text
SDL  displayed 196 frames
SFML displayed 5559 frames
--> SFML is 28.4x as fast as SDL

Thou interesting, if v-sync was set, why was sdl ignoring it, while sfml wasn't?
Title: Re: Benchmark : SDL vs SFML
Post by: victorlevasseur on August 19, 2012, 12:21:58 pm
SDL don't use the graphic card (so, don't use its settings).
Without V-sync, we can see that SFML is still "better" than SDL in terms of performances.
Title: Re: Benchmark : SDL vs SFML
Post by: AdelR on August 19, 2012, 01:04:35 pm
I was under the impression that new SDL was using hardware acceleration like SFML.
Title: Re: Benchmark : SDL vs SFML
Post by: Mario on August 19, 2012, 01:09:13 pm
To be honest, I consider this test a bit unfair, comparing GPU rendering to software rendering (IIRC SDL 1.2 is still on software, not sure about SDL 1.3/2.0).

Anyway, the difference is even more noticeable with a CPU that's a bit dated and a GPU that's state-of-the-art (Core 2 Quad 3 GHz, Geforce GTX 680; both on stock values/timing):

Quote
1/ Test : sprites
SDL  displayed 88 frames
SFML displayed 1129 frames
--> SFML is 12.8x as fast as SDL

2/ Test : alpha-blended sprites
SDL  displayed 38 frames
SFML displayed 1111 frames
--> SFML is 29.2x as fast as SDL

3/ Test : rotating sprites
SDL  displayed 26 frames
SFML displayed 1148 frames
--> SFML is 44.2x as fast as SDL

4/ Test : static text
SDL  displayed 1908 frames
SFML displayed 20391 frames
--> SFML is 10.7x as fast as SDL

5/ Test : dynamic text
SDL  displayed 142 frames
SFML displayed 3809 frames
--> SFML is 26.8x as fast as SDL
Title: Re: Benchmark : SDL vs SFML
Post by: eXpl0it3r on August 19, 2012, 01:22:31 pm
To be honest, I consider this test a bit unfair, comparing GPU rendering to software rendering (IIRC SDL 1.2 is still on software, not sure about SDL 1.3/2.0).
Well people often don't take that perspective into account, put SFML and SDL on the same level and argue about what's better etc. without really testing it. So this benchmark is not about fairness, it's about comparing the two libraries and providing facts that SFML should not only be the library of choice because of it's astetics (nice & clean C++ abstractions) but also because in most cases it performs better than SDL. ;)
Additionally the first benchmark was for SFML 1.x which also did quite a bit more stuff on the CPU rather than the GPU.

It's very interesting to see how vsync can limit SFML and that SFML performs also quite good on PCs with a better GPU than a CPU.

What the test actually fails to include is the judging of the output. I mean on my PC the sprite rotations with SDL just stutter and are useless where as the ones with SFML run smoothly.
Title: Re: Benchmark : SDL vs SFML
Post by: pdinklag on August 19, 2012, 02:30:52 pm
You might want to do a test using SDL_gfx as well.
It's a very common SDL extension that does smooth rotations, scaling and features drawing of primitives.

Back in the day, I used it and rotations were pretty smooth.
http://www.ferzkopp.net/joomla/content/view/19/14/

I think add-ons like these are making SDL hard to compare to SFML. Not idea if they should be considered for benchmark tests like these...

I can't really tell what's more common, SGE or SDL_gfx. But personally I didn't know SGE yet.
Title: Re: Benchmark : SDL vs SFML
Post by: eXpl0it3r on August 19, 2012, 02:59:42 pm
If you know your way around SDL_gfx you could rewrite the test for it. I'm not familiar with SDL at all, so I'd have to dig deeper into it.

Of course diffrent modules makes it hard to compair but as I already stated earlier most people just argue about if SDL is better than SFML and those are mostly the same people that will use extentions like SGE or SDL_gfx. Also if you'd just want to do a pure SDL comparison then you'll probably just have to look at the first two tests and maybe add a pixel manipulation test. That's another factor where SFML shines, it isn't limited to just drawing images but provides much more and doesn't require you to make decisions between diffrent extentions. ;)
Title: Re: Benchmark : SDL vs SFML
Post by: Laurent on August 19, 2012, 08:12:10 pm
Oh please, don't start the "GPU vs CPU" discussion again.

And as far as I remember, SDL 2.0 has a totally different API with windows and renderers -- and it is hardware accelerated. So this "new" benchmark is obviously not using it, and is just equivalent to the old one.
Title: Re: Benchmark : SDL vs SFML
Post by: eXpl0it3r on August 19, 2012, 09:43:40 pm
Oh please, don't start the "GPU vs CPU" discussion again.
Again? Must have been before my time. ;)

And as far as I remember, SDL 2.0 has a totally different API with windows and renderers -- and it is hardware accelerated. So this "new" benchmark is obviously not using it, and is just equivalent to the old one.
Yeah it was never my idea to make a new comparision, I just revived the old one but now for SFML 2. Maybe if some SDL user want he could implement it for SDL 2. :)
Title: Re: Benchmark : SDL vs SFML
Post by: Laurent on August 19, 2012, 09:57:42 pm
Since SDL 1.2 is many years old, and SDL 2.0 is coming in a few weeks, it would be more than fair to make the comparison with the new version. Using the old SDL 1.2 adds nothing to this topic.
Title: Re: Benchmark : SDL vs SFML
Post by: Qix on September 20, 2012, 01:16:01 pm
Oh please, don't start the "GPU vs CPU" discussion again.

And as far as I remember, SDL 2.0 has a totally different API with windows and renderers -- and it is hardware accelerated. So this "new" benchmark is obviously not using it, and is just equivalent to the old one.

Indeed it does. SDL 2.0 is hardware accelerated, and its structure is kind of similar to SFML's WindowRenderer and TextureRenderer classes (IIRC).

However, as far as complexity goes, SFML is the better choice for OOP base infrastructure, simply because it was built for it.

However, it'd be interesting to benchmark with SDL 2.0. Good luck getting the layout of the code to work; the workflow and API diagrams are incredibly different between SDL2 and SFML.
Title: Re: Benchmark : SDL vs SFML
Post by: swarminglogic on May 29, 2013, 02:30:12 am
In case anyone wanted an updated benchmark, using hardware accelerated SDL 2.0.0, instead of software rendering in SDL 1.2, it's available here: https://github.com/swarminglogic/SFML-vs-SDL-Benchmark (https://github.com/swarminglogic/SFML-vs-SDL-Benchmark)

The results between SDL and SFML are much closer now.

PS: Hi everyone, I'm new here.
PPS: Sorry if it's bad to reply to an old post.
Title: Re: Benchmark : SDL vs SFML
Post by: Cornstalks on May 29, 2013, 02:57:44 am
The results between SDL and SFML are much closer now.
Would be interesting to hear what your hardware (and results) are.
Title: Re: Benchmark : SDL vs SFML
Post by: swarminglogic on May 29, 2013, 09:57:03 am
The results between SDL and SFML are much closer now.
Would be interesting to hear what your hardware (and results) are.

Sure thing.
16GB RAM, 2x Intel(R) Xeon(R) CPU  E5420 @ 2.50GHz, NVIDIA Corporation G92 [GeForce 8800 GT]

Results (edit: Re-ran the 5-6 times, this is the most common result)

1/ Test : sprites
SDL  displayed 903 frames
SFML displayed 890 frames
--> SDL is 1.01x as fast as SFML

2/ Test : alpha-blended sprites
SDL  displayed 576 frames
SFML displayed 575 frames
--> SDL is 1.00x as fast as SFML

3/ Test : rotating sprites
SDL  displayed 869 frames
SFML displayed 873 frames
--> SFML is 1.00x as fast as SDL

4/ Test : static text
SDL  displayed 26778 frames
SFML displayed 27033 frames
--> SFML is 1.01x as fast as SDL

5/ Test : dynamic text
SDL  displayed 194 frames
SFML displayed 5061 frames
--> SFML is 26.09x as fast as SDL


Test 5 suffers on the SDL side because of a bad way of doing it (which requires allocation/deallocation of SDL_Surface, conversion to- and deallovation of an SDL_Texture, per line of text, pr frame).

I'll test on my home computer later. For what it's worth, I don't think this is a particularly excellent benchmark since it doesn't cover much of the frameworks, but I've seen this benchmark referred to several times as indication for how much faster SFML is, which didn't seem right to me. At least now it's comparing the same thing.

Edit: I also don't like how it's using two different timers for the different tests. It would be better to either stick with one of them, or just use std::chrono, or similar. It could also draw something before starting the timer, to make sure it doesn't have hidden startup costs.
Title: Re: Benchmark : SDL vs SFML
Post by: Laurent on May 29, 2013, 10:12:58 am
Quote
Sorry if it's bad to reply to an old post.
It's ok, except for this particular thread ;D

Let's close it before it does more damage.