JS Data Types for iPhone

Just out of curiosity… Does anyone know if using ‘sbyte’ or ‘short’ for replacing integers is actually worth it for devices like the iPhone?

Will I see a big difference? Is it worth my time?

Thanks!

It should not be much different than an int. If you do see any performance it will be in calculating millions of them per second. That would border on application and not game though.

What I’ve read is that it’s bad for performance, because modern hardware is optimized to work with floats and ints. But if you need the memory, then you need to take the performance hit, so your app doesn’t crash. You probably should not concern yourself with this idea; I think it’s unlikely a Unity app is going to crash for this reason.

I think for some compilers, its faster to use int, float etc due to overhead. That is very compiler dependent though (and some will treat a boolean like an int internally, for example).

However, faster loading and saving comes from smaller files, so that is where they will be valuable. Also I gained plenty of speed using shorts and such by packing my vert struct very tightly on iphone for my old 2D game. In unity, I honestly doubt there’s speed gains beyond file i/o from using smaller data types.

It depends on the CPU. On my Xeon, int (32 bit) is the fastest, with byte (8 bit) being about 10% slower, and short (16 bit) and long (64 bit) being 20% slower. On the A4 of my iPod touch 4, the differences are much greater, with int being the fastest, long and byte being 60% slower, and short being 130% slower. So it looks like you’d generally want to avoid short (at least by itself) on iOS unless you really need the RAM.

–Eric