Has anyone compared monkey to unity speed

Monkey Forums/Monkey Programming/Has anyone compared monkey to unity speed

smilertoo(Posted 2014) [#1]
Hi,
Has anyone compared how fast monkey can do 2d compared to unity? I'm interested in doing a shooter with LOTS of bullets and enemies and the unity pooling system seems like it might have quite a big overhead.


Xaron(Posted 2014) [#2]
I know both in and out and actually Monkey is faster than Unity when it comes to 2d stuff. Not to mention that the package size of an empty Unity project is about 8MB.

But I think both should be good enough to do the job so it's more a matter of preferences. Today Unity 4.5 came out with lots of 2d improvements, even though I haven't looked at it yet, it looks good. What really bugs me is still the old Mono stuff with its outdated garbage collector which won't even change in Unity 5.0...


dragon(Posted 2014) [#3]
Monkey work with floats...
OpenGL support also short types

i did a test a time ago...
and shorts are 2x faster for many small objects...


monkey also transform every image...
this is good for many scaled, rotated objects...

but if you have a tilemap - or non scaled, non rotated objects (=all objects have same scale, rotation), it is possible to disable transforms - this give again some % more speed...


both is not implemented today in monkey...

here is my old test:
http://www.monkey-x.com/Community/posts.php?topic=3711




so... on drawing side, here is some potencial... in some cases (many small objects)

on code executing side - here is nearly no potencial, because monkey is not a script (like lua, unity)


smilertoo(Posted 2014) [#4]
From that i am not sure if you're saying monkey is faster or not; there's things that make it faster but they're not implemented?


Gerry Quinn(Posted 2014) [#5]
One advantage of Monkey is that you have more programming flexibility. E.g. if garbage collection is an issue it would probably be easier to code in such a way as to avoid it. That said, there are almost certainly things that each does better than the other. I would be inclined not to worry too much about whether one is more efficient.


tiresius(Posted 2014) [#6]
I have no interest in Unity whatsoever....
but maybe someone (such as Xaron) can whip up a quick example of 500 sprites bouncing off the edges of the screen in both Unity and Monkey, using similar techniques, and see what type of FPS, Memory and application size footprint they get? It is a simplistic example, I know, but would be interesting to see.


Xaron(Posted 2014) [#7]
Nice idea, might do it! :)


Lindsay(Posted 2014) [#8]
I'd like to see that comparative test too! I have looked at Unity 4.5, but for 2D it seems to me they've added it on as a layer but their primary focus is 3D. I must admit, though, I was very surprised and impressed that it created a working Windows version on Mac without any other development tools!


Xaron(Posted 2014) [#9]
Alright guys, I've did it and here are the numbers:

I've used 2000 sprites which move randomly over the screen. Results are:

Unity 4.5
APK size: 8.404.358 bytes
FPS: ~20

Monkey v79c
APK size: 67,331 bytes
FPS: ~33 (previous value of 200 was wrong)

Unity C# code:


Monkey code:


Sample APKs:
Unity: http://www.leidel.net/dl/monkey/2dtest/unitytest.apk
Monkey: http://www.leidel.net/dl/monkey/2dtest/monkeytest.apk

Actually I'm pretty shocked how much faster Monkey is!


Xaron(Posted 2014) [#10]
Let's see the reactions:
http://forum.unity3d.com/threads/248926-Speed-comparison-2d-Unity-vs-Monkey
http://forums.toucharcade.com/showthread.php?t=230896


Danilo(Posted 2014) [#11]
@Xaron:
Where is 'Sprite.png' you used?
What's the dimensions of 'Sprite.png' you used for testing?
Unity code does not look like it is loading same 'Sprite.png'?


therevills(Posted 2014) [#12]
If you download the APK you can open it using a unzip program (such as WinRAR).

The Sprite.png is 64x64.

I would say the Unity code uses the same image but as a project resource.


Xaron(Posted 2014) [#13]
That's true. Here are the projects:
http://www.leidel.net/dl/monkey/2dtest/unityproject.zip
http://www.leidel.net/dl/monkey/2dtest/monkeyproject.zip


Danilo(Posted 2014) [#14]
Thanks!


Xaron(Posted 2014) [#15]
Interesting discussion is going on in the Unity forum. :D Basically they say that I must be wrong.


Goodlookinguy(Posted 2014) [#16]
The Unity people are becoming very defensive. Do they not realize that other systems exist outside of Unity and that Unity isn't the necessarily the best?

Edit: They also seem to have a hard time understanding your code. Are most people over there inexperienced or something?


dragon(Posted 2014) [#17]
xaron...
just render 10x more sprites in monkey... to get 20 fps... :-)
200 fps confuse some people

it do not shocked me that unity is slower in 2D.
But again... monkey have some potential to double speed in some cases...



a long time ago i compared BlitzMax, Irrlicht... and something else...
and BlitzMax was faster...



I remember also - a time ago i wrote my own OpenGL-Engine for Android... i used floats - but it was very slow... I think here are some ways to draw triangles... some faster, some slower... finally i was able to make it fast with some tricks... evtl. unity do the same mistake (?)


tiresius(Posted 2014) [#18]
They take issue with the way the FPS is calculated on Monkey side.

I am new to mobile stuff but,
Xaron, can't an Android phone show "debug" information itself, cpu %, and actual FPS? It does on my cheapo one so I'm assuming other phones can as well.
Maybe that will settle it.


Goodlookinguy(Posted 2014) [#19]
Xaron could just calculate FPS the classic way, but it won't make a difference really because Monkey will just max out at 60 and still leave Unity in the dust. They're just a bunch of whiners.


Lindsay(Posted 2014) [#20]
Yeah, I read the Unity forum last night and was quite amused by how defensive they got!

I'm sticking with Monkey. I just wish there was more I could do to support it financially! If my game sells a million ... ;)


nori(Posted 2014) [#21]
i think it's also good to observe at how many sprites it starts to jitter and become unplayable. that can be trusted as long as just the render code is ok

another point is, when i stress tested a cheap android device with many/big sprites, not only the drawing lagged, i believe the touch response time went down too because the sound (soundpool) triggering also started to lag. also, the music from the mediaplayer object stuttered, and at some stress level the device occasionally crashed


consty(Posted 2014) [#22]
It's no joke that at very best your monkey code will be translated to native C++ - it depends on the target you choose.

Unity runs all scripts on Mono virtual machine so this theoretically brings the so called bottleneck problem into question.

On the other hand Monkey remains pure C++ all of the time - again this depends on target - so thus having virtually lots of more efficiency.

Personally having used Unity I respect what it offers but also now by discovering Monkey I find many other interesting uses for it and it takes even more of my daily time.


Xaron(Posted 2014) [#23]
Alright, I have to admit that I was indeed wrong with my fps counter. I've adapted the fps code to measure the time between two render calls now. Using this code, I get 33 fps for Monkey which is more realistic and still 65% faster than Unity. Thanks again and sorry for that! I'm still very satisfied with these results. ;)


Goodlookinguy(Posted 2014) [#24]
Hmm?

I've adapted the fps code to measure the time between two render calls now


That still seems wrong. Maybe your wording is odd.

This is an example of how it's usually done. Calculating the difference between only 2 frames is inaccurate, you have to average over a second of time.



Xaron(Posted 2014) [#25]
I do it that way now, I've edited the code above in my posting.


Rudenko(Posted 2014) [#26]
Hi all, can someone test also love2d please, pc performance.
thanks :)


Goodlookinguy(Posted 2014) [#27]
love2d uses the Lua VM and is likely to be slower as well. Monkey is more than likely always going to be faster because it uses native code.


Pharmhaus(Posted 2014) [#28]
the newest version of love2d uses rocklua (jit) by default, so who knows?


Goodlookinguy(Posted 2014) [#29]
(jit)


Well, that at least confirms that its startup time will be worse than Monkey's.


smilertoo(Posted 2014) [#30]
Is that 8mb vs 67k ?


Rudenko(Posted 2014) [#31]
Xaron

i just test your apk's on nexus 7 (2013)

Unity = 33-35 fps

Monkey = 59-60 fps


Xaron(Posted 2014) [#32]
@smilertoo, yes 8MB vs 67k

@Rudenko: Thanks for the numbers! :) fps are capped at 60fps actually so it would be best to render even more sprites.


EdzUp(Posted 2014) [#33]
Well tbh both can be used for big projects but monkey for me is more simple and easier to use, I would like byte data types to be implemented though as it is very handy :)


ziggy(Posted 2014) [#34]
love2d uses the Lua VM and is likely to be slower as well. Monkey is more than likely always going to be faster because it uses native code.
mmm Not in XNA nor JavaScript or Android. So all in all, if Monkey is faster is maybe because it's better done, and does not require lots of workarounds to mimic the CLI over Dalvik, or in case of LUA, adding a VM on top of another.


Goodlookinguy(Posted 2014) [#35]
ziggy, I was talking about the PC platform which is GLFW or the BlitzMax target. I was not talking about all platforms.


Xaron(Posted 2014) [#36]
Well that thread over there at Unity becomes interesting. :D

http://forum.unity3d.com/threads/speed-comparison-2d-unity-vs-monkey.248926/


Lindsay(Posted 2014) [#37]
Their 2d implementation is the biggest kludge I've seen in a long time. I honestly don't know why they bothered! Perhaps it will improve in time - especially if they do modularise the engine - but for now, forget it!


Qube(Posted 2014) [#38]
I was enjoying Unity right up until the point I realised something... It sucks!!!

I found myself fighting every step of the way with camera setup, sprite sheets (and their quality), GUI etc etc. No matter how many plugins I bought it was always a fight, something new to groan and roll my eyes at. Unity is drag, drop, little script, go, that's it's bag plain and simple. Yeah, yeah you can code everything if you so wish but it's OOP crazy. This.that.withThis.that.andThis.plusThat = moreOfThis.that.withThis.ohAndThat.plusThis... Shear madness.

For those who love Unity I'm sure it's great and all that but from someone who like the classic form of coding and to actually "write" apps it's suck more than a Henry Hover on steroids.

I'm currently being paid to write a game which unfortunately Monkey doesn't have the iOS features needed (camera, gallery) so I bought AGK and within one day I had done more than I had done with Unity over a month (I had to learn both systems).

I digress.... Monkey is faster than Unity but does this really matter these days? - If your game requires so much going on where every cycle is critical then I suppose the answer is yes. However.. The shear power of systems these days (even smart devices) allows quite a lot of room for speed differences, unless the output from the dev environment really really sucks.

From a personal point of view I've done speed tests (mainly raw graphical performance) for iOS on Monkey, GLBasic, Unity and AGK. They are all easily good enough so it just comes down to what you are most comfortable with and if they support the features you need.

Unity has been a big waste of time and money for me and although I do keep fiddling with it I do find it a system which has had bolt on after bolt on followed by kludge this feature in and wedge X feature on top. As said, if you like drag and drop > add physics add-on > quick bit of script > GO! then Unity is perfect for that. If you want a clean, fast, straight coding environment then skip it.


zoqfotpik(Posted 2014) [#39]
What I don't understand is why the inferiority complex from the Unity crowd. Their engine is great looking and has much greater market penetration than Monkey does.

Is it possible that apps written in Fortran and designed for x-ray crystallography are better at x-ray crystallography than Unity is? Would saying so be an attack on Unity?


Lindsay(Posted 2014) [#40]
Is it possible that apps written in Fortran ...


Fortran ... now that's a name I've not heard in a long time. A long time! ;)


consty(Posted 2014) [#41]
Is it possible that apps written in Fortran and designed for x-ray crystallography are better at x-ray crystallography than Unity is? Would saying so be an attack on Unity?

The only case that would be valid, if only these developers were highly skilled and their specialty was x-ray crystallography. I doubt if the programming language of choice would matter, because technologically the project will be developed anyhow, this would be mostly a matter of corporate identity and business politics.


Nobuyuki(Posted 2014) [#42]
Maybe a lot of amateur/semi-pro devs have already invested heavily in learning (and paying for) Unity and don't want to see a $99 piece of software beat it out in such a simple test.

I mean, that's really the problem, isn't it? You can make so many amazing things with Unity but it's still suited more for specific tasks and the runtime's probably way over-built for just simple 2d apps. Only my two cents, have not dug that deep into it.

Edit: Also the arguments about "Who cares about a measly 7.5mb" on mobile hurt my poor heart. My phone only has 8gb of space, and for apps that can't be transferred to "external", only 1gb is made available. I constantly run out of space and have to delete any apps I don't use. 7mb makes a huge difference in my download decisions.


Edit2: And the argument that monkey is not well-suited to many graphical projects, well it can mix 3d in using raw ogl calls, but they're right about shaders not being available. I would really really like to see shaders become available and would even pay for Monkey2 if that's what would need be for it to happen.

Same for some better audio support, but people on this forum are doing a very good job of porting audio libs like libmodplug and bass to the various platforms and having it work with Monkey. Maybe the only thing it's missing is FMod Studio support, I hear they have a superb system for designing cues, but no matter.

Edit3:
Plus c# verses basic? oh come on.

I will never stop being frustrated at the stupidity of statements like the above. Many of us cut our teeth on BASIC, the syntax is approachable and verbose enough to be easily readable at a glance. C# is great, they fixed a lot of problems with C++ but it's still c-style syntax and not everyone digs that. I can't tell if this guy was bashing BASIC syntax in general or trying to appeal to old prejudices that all BASIC languages are "toys" but this really gets my goat, particularly these days when people should know better with all the new languages flourishing.


Gerry Quinn(Posted 2014) [#43]
Const, I'm pretty sure that Unity would be a pretty bad choice compared to Fortran for X-Ray crystallography! I'm sure you could do it, given the power of modern hardware, but really, there is no reason to do such a thing.


Gerry Quinn(Posted 2014) [#44]
Heh, language wars are fun so long as people don't take them too seriously! I think Monkey vs Unity is unlikely to get too extreme because most people can clearly see that each has advantages in different scenarios.


Arjailer(Posted 2014) [#45]
I use C# all day at work and for hobby projects too, and I love it.

But turning your nose up at Monkey for being Basic is pretty much admitting that you've never looked at if beyond "it's Basic". It's the feature set that makes Monkey great (not the least of which is all the targets it compiles to) - the actual language syntax is largely irrelevant and took me all of two hours to get used to :-)


Paul - Taiphoz(Posted 2014) [#46]
is monkey basic ?

I ask honestly I mean define basic, I grew up with Amstrad CPC Basic and monkey is nothing like that, so I would love for some one to actually quantify this "its basic" for me and explain it, because to me there is very little if anything basic about monkey.


nori(Posted 2014) [#47]
yeah, no goto x)


Salmakis(Posted 2014) [#48]
lol this "basic vs c#" statement is so poor, specially when you think that monkey outputs c# on XNA (isnĀ“t it?)


Nobuyuki(Posted 2014) [#49]
It's all about the syntax. Blocks in Monkey resemble BASIC blocks, as do many of the reserved keywords resemble the most common BASIC dialects these days. Other aspects seem to resemble a number of other semi-modern languages in their execution such as vb.net, js, as, and java. A lot of "functional" and multithreaded concepts from many of the latest generation of languages don't exist (yet). Similar words (not all are keywords but most are): Function, If/Then/ElseIf/Else, Rem, For/Next, Select/Case, Print, While/Wend, End, Continue, Return.

There are also a lot of differences which make Monkey unique and not directly inspired by any of these. Moreso I would say than UnityScript or UnrealScript, as it seems to have hints of aspirations to be a complete language rather than just an internal script for its own toolchain.


Gerry Quinn(Posted 2014) [#50]
I'd call it a cross between Basic and Java, syntax-wise. At least that's how it appeared to me when I first set eyes on it.

Also, most of the traditional looking Basics like Blitz and Power are not your grandad's Basic - they have absorbed a lot of C.