Blog post about these results coming soon on the Learn Cocos2D blog.

All Cocos2D tests were made with Cocos2D v1.0.1 stable release. The various texture atlas images were created with TexturePacker, the Tilemaps were created with Tiled Map Editor.

The performance measuring code is based on Mike Ash's performance test code as well as the iPhone version ported by an "aussie bloke" (Stuart Carnie).


iPad 1 (iOS 5.0.1) iPod 4th Generation (iOS 5.0.1) iPhone 3G (iOS 4.2.1)
A nanosecond (ns) is one billionth of a second (0.000 000 001 second). One nanosecond is to one second as one second is to 31.7 years. One Gigahertz (GHz) equals 1,000,000,000 Hz. One cycle of a 1 GHz CPU takes 1 nanosecond.

Array Tests

Testing Cocos2D's CCArray performance against regular NSMutableArray.

NameEach (ns)
NSMutableArray objectAtIndex:77
CCArray objectAtIndex:82
CFArray GetValueAtIndex136
CCArray exchangeObjectAtIndex254
CCArray withCapacity addObject:325
CCArray addObject:373
NSMutableArray insertObject: atIndex:0478
NSMutableArray withCapacity addObject:604
NSMutableArray addObject:622
CCArray removeLastObject664
NSMutableArray removeLastObject1.039
CCArray removeObjectAtIndex1.569
NSMutableArray removeObjectAtIndex1.784
NSMutableArray exchangeObjectAtIndex1.985
CCArray indexOfObject15.309
CCArray containsObject15.506
CCArray fast enumeration22.050
NSMutableArray fast enumeration28.418
NSMutableArray indexOfObject38.334
NSMutableArray containsObject40.514
CCArray insertObject: atIndex:056.976
NSMutableArray enumeration84.579
CCArray enumeration88.456
NSMutableArray makeObjectsPerformSelector withObject121.212
CCArray makeObjectsPerformSelector withObject128.970
NSMutableArray makeObjectsPerformSelector183.931
CCArray makeObjectsPerformSelector234.260
NSMutableArray add/removeObjectsInArray883.085
CCArray add/removeObjectsInArray2.398.743

Object Creation

These tests tell you how long it takes to allocate memory, initialize the object, and deallocate it. The longer this takes for an object, the higher the chance that doing this during gameplay will negatively affect performance. Note that these tests do not give any indication whatsoever of the runtime/rendering performance of these objects.

NameEach (ns)
NSAutoreleasePool alloc/init/release630
NSObject alloc/init/release3.137
CCNode alloc/init/release3.928
CCMoveTo alloc/init/release4.259
CCSequence alloc/initOne/release5.096
CCSprite alloc/initWithFile/release23.554
CCParticleSystemQuad 25 particles alloc/init/release168.798
CCParticleSystemQuad 250 particles alloc/init/release413.338
CCLabelTTF alloc/initWithString/release579.575
CCLabelBMFont alloc/initWithString/release653.608
CCTMXTiledMap small alloc/init/release15.724.142
CCTMXTiledMap large alloc/init/release1.129.904.604

Loading Textures

Time it takes to load and unload the same 1024x1024 texture using a variety of different image file formats, compression and color bit depths.

NameEach (ns)
PVRTC4.pvr.ccz651.275
PVRTC2.pvr.ccz748.332
PVRTC2.pvr5.574.554
PVRTC4.pvr8.747.835
PVRTC2.pvr.gz12.382.721
PVRTC4.pvr.gz21.729.260
RGB565.pvr28.060.432
RGBA5551.pvr28.422.838
RGBA4444.pvr28.423.882
RGBA4444.pvr.ccz39.611.505
RGBA5551.pvr.ccz41.135.829
RGB565.pvr.ccz41.304.006
RGBA4444.pvr.gz46.920.818
RGBA5551.pvr.gz47.976.535
RGB565.pvr.gz49.175.556
RGBA8888.pvr54.818.895
RGBA8888.pvr.ccz81.683.766
RGBA8888.pvr.gz95.916.186
RGB565.png113.274.316
RGBA5551.png114.599.338
RGBA4444.png115.231.899
RGBA8888.png127.134.580
RGBA8888.jpg851.384.812
RGBA5551.jpg865.443.154
RGBA4444.jpg867.075.779
RGB565.jpg870.333.871

Node Hierarchy (children)

The performance of functions that act on the node hierarchy (children list) depends heavily on the number of children.

NameEach (ns)
getChildByTag w/ 10 Nodes642
reorderChild w/ 10 Nodes3.728
getChildByTag w/ 100 Nodes3.960
reorderChild w/ 100 Nodes9.322
addChild with tag9.903
getChildByTag w/ 500 Nodes20.861
removeChildByTag22.331
reorderChild w/ 500 Nodes33.852
getChildByTag w/ 2,500 Nodes123.275
reorderChild w/ 2,500 Nodes179.381

Messaging / Function Calls

Low-level overhead for calling C++ functions respectively sending Objective-C messages in various ways.

NameEach (ns)
C++ virtual method call13
IMP-cached message send17
C++ cached virtual method call30
Objective-C message send37
NSInvocation message send439

Arithmetic Tests

Simple calculations done frequently in an app, using various data types.

NameEach (ns)
Integer multiplication10
Float multiplication36
Double multiplication47
Integer division48
Float division with int conversion72
Float division73
Float square root106
Double division108
Double division with int conversion111
Double square root148
Accelerometer Highpass filter267

Memory Tests

Allocating and releasing memory.

NameEach (ns)
16 byte memcpy26
16 byte malloc/free503
16MB malloc/free14.629
1MB memcpy1.087.525

File IO

NameEach (ns)
Read 16MB file121.258
Read 16-byte file124.130
Write 16-byte file499.013
Write 16-byte file (atomic)819.701
Write 16MB file880.762
Write 16MB file (atomic)1.134.361

Miscellaneous Tests

NameEach (ns)
Zero-second delayed perform294
pthread create/join142.973

A nanosecond (ns) is one billionth of a second (0.000 000 001 second). One nanosecond is to one second as one second is to 31.7 years. One Gigahertz (GHz) equals 1,000,000,000 Hz. One cycle of a 1 GHz CPU takes 1 nanosecond.

Array Tests

Testing Cocos2D's CCArray performance against regular NSMutableArray.

NameEach (ns)
NSMutableArray objectAtIndex:100
CCArray objectAtIndex:105
CFArray GetValueAtIndex176
CCArray exchangeObjectAtIndex324
CCArray withCapacity addObject:416
CCArray addObject:419
NSMutableArray insertObject: atIndex:0572
NSMutableArray withCapacity addObject:687
NSMutableArray addObject:688
CCArray removeLastObject857
NSMutableArray removeLastObject1.336
CCArray removeObjectAtIndex2.040
NSMutableArray removeObjectAtIndex2.328
NSMutableArray exchangeObjectAtIndex2.592
CCArray containsObject19.886
CCArray indexOfObject19.962
CCArray fast enumeration28.560
NSMutableArray fast enumeration36.668
NSMutableArray indexOfObject49.743
NSMutableArray containsObject52.521
CCArray insertObject: atIndex:072.364
NSMutableArray enumeration109.026
CCArray enumeration114.515
NSMutableArray makeObjectsPerformSelector withObject153.813
CCArray makeObjectsPerformSelector withObject167.441
NSMutableArray makeObjectsPerformSelector238.568
CCArray makeObjectsPerformSelector250.246
NSMutableArray add/removeObjectsInArray953.803
CCArray add/removeObjectsInArray3.090.132

Object Creation

These tests tell you how long it takes to allocate memory, initialize the object, and deallocate it. The longer this takes for an object, the higher the chance that doing this during gameplay will negatively affect performance. Note that these tests do not give any indication whatsoever of the runtime/rendering performance of these objects.

NameEach (ns)
NSAutoreleasePool alloc/init/release892
NSObject alloc/init/release4.050
CCNode alloc/init/release5.099
CCMoveTo alloc/init/release5.504
CCSequence alloc/initOne/release6.680
CCSprite alloc/initWithFile/release29.451
CCParticleSystemQuad 25 particles alloc/init/release154.623
CCParticleSystemQuad 250 particles alloc/init/release508.432
CCLabelTTF alloc/initWithString/release739.952
CCLabelBMFont alloc/initWithString/release847.045
CCTMXTiledMap small alloc/init/release18.578.580
CCTMXTiledMap large alloc/init/release1.438.647.079

Loading Textures

Time it takes to load and unload the same 1024x1024 texture using a variety of different image file formats, compression and color bit depths.

NameEach (ns)
PVRTC4.pvr.ccz904.563
PVRTC2.pvr.ccz917.834
PVRTC2.pvr6.600.616
PVRTC4.pvr10.321.815
PVRTC2.pvr.gz15.267.200
PVRTC4.pvr.gz27.684.074
RGB565.pvr32.698.952
RGBA4444.pvr32.708.815
RGBA5551.pvr32.889.440
RGBA4444.pvr.ccz47.412.733
RGBA5551.pvr.ccz48.655.328
RGB565.pvr.ccz49.367.906
RGBA4444.pvr.gz58.213.932
RGBA5551.pvr.gz59.741.089
RGB565.pvr.gz60.072.209
RGBA8888.pvr63.956.478
RGBA8888.pvr.ccz97.924.909
RGBA8888.pvr.gz117.333.748
RGB565.png135.442.519
RGBA5551.png137.939.474
RGBA4444.png138.107.768
RGBA8888.png149.741.913
RGBA8888.jpg1.088.439.833
RGBA5551.jpg1.099.894.992
RGBA4444.jpg1.101.358.371
RGB565.jpg1.102.385.583

Node Hierarchy (children)

The performance of functions that act on the node hierarchy (children list) depends heavily on the number of children.

NameEach (ns)
getChildByTag w/ 10 Nodes846
reorderChild w/ 10 Nodes4.799
getChildByTag w/ 100 Nodes5.163
reorderChild w/ 100 Nodes11.768
addChild with tag12.631
getChildByTag w/ 500 Nodes27.561
removeChildByTag29.432
reorderChild w/ 500 Nodes44.279
getChildByTag w/ 2,500 Nodes156.393
reorderChild w/ 2,500 Nodes227.192

Messaging / Function Calls

Low-level overhead for calling C++ functions respectively sending Objective-C messages in various ways.

NameEach (ns)
C++ virtual method call16
IMP-cached message send22
C++ cached virtual method call39
Objective-C message send48
NSInvocation message send569

Arithmetic Tests

Simple calculations done frequently in an app, using various data types.

NameEach (ns)
Integer multiplication12
Float multiplication47
Double multiplication61
Integer division63
Float division93
Float division with int conversion94
Float square root137
Double division140
Double division with int conversion145
Double square root190
Accelerometer Highpass filter346

Memory Tests

Allocating and releasing memory.

NameEach (ns)
16 byte memcpy34
16 byte malloc/free649
16MB malloc/free21.227
1MB memcpy1.178.374

File IO

NameEach (ns)
Read 16-byte file149.936
Read 16MB file156.952
Write 16-byte file660.388
Write 16-byte file (atomic)943.402
Write 16MB file (atomic)1.043.194
Write 16MB file1.044.325

Miscellaneous Tests

NameEach (ns)
Zero-second delayed perform5
pthread create/join180.477

A nanosecond (ns) is one billionth of a second (0.000 000 001 second). One nanosecond is to one second as one second is to 31.7 years. One Gigahertz (GHz) equals 1,000,000,000 Hz. One cycle of a 1 GHz CPU takes 1 nanosecond.

Array Tests

Testing Cocos2D's CCArray performance against regular NSMutableArray.

NameEach (ns)
CCArray objectAtIndex:380
NSMutableArray objectAtIndex:460
CCArray exchangeObjectAtIndex1.136
CFArray GetValueAtIndex1.514
CCArray addObject:3.532
CCArray withCapacity addObject:3.562
NSMutableArray insertObject: atIndex:05.567
NSMutableArray withCapacity addObject:6.017
NSMutableArray addObject:6.173
CCArray removeLastObject9.820
NSMutableArray removeLastObject10.938
CCArray removeObjectAtIndex27.121
NSMutableArray removeObjectAtIndex32.427
NSMutableArray exchangeObjectAtIndex41.978
CCArray containsObject58.970
CCArray indexOfObject63.629
CCArray fast enumeration84.829
NSMutableArray fast enumeration110.895
NSMutableArray containsObject159.196
NSMutableArray indexOfObject160.993
CCArray insertObject: atIndex:0360.513
NSMutableArray enumeration463.399
NSMutableArray makeObjectsPerformSelector508.814
NSMutableArray makeObjectsPerformSelector withObject541.626
CCArray makeObjectsPerformSelector681.136
CCArray makeObjectsPerformSelector withObject703.787
CCArray enumeration724.694
NSMutableArray add/removeObjectsInArray6.701.924
CCArray add/removeObjectsInArray9.801.766

Object Creation

These tests tell you how long it takes to allocate memory, initialize the object, and deallocate it. The longer this takes for an object, the higher the chance that doing this during gameplay will negatively affect performance. Note that these tests do not give any indication whatsoever of the runtime/rendering performance of these objects.

NameEach (ns)
NSAutoreleasePool alloc/init/release10.672
NSObject alloc/init/release19.240
CCNode alloc/init/release25.884
CCMoveTo alloc/init/release26.179
CCSequence alloc/initOne/release41.992
CCSprite alloc/initWithFile/release149.578
CCParticleSystemQuad 25 particles alloc/init/release400.082
CCParticleSystemQuad 250 particles alloc/init/release730.617
CCLabelTTF alloc/initWithString/release3.411.428
CCLabelBMFont alloc/initWithString/release3.792.740
CCTMXTiledMap small alloc/init/release82.298.633
CCTMXTiledMap large alloc/init/release6.078.265.400

Loading Textures

Time it takes to load and unload the same 1024x1024 texture using a variety of different image file formats, compression and color bit depths.

NameEach (ns)
PVRTC4.pvr.ccz4.932.652
PVRTC2.pvr.ccz5.143.908
PVRTC2.pvr20.710.732
PVRTC4.pvr33.422.953
PVRTC2.pvr.gz46.133.937
PVRTC4.pvr.gz86.878.310
RGB565.pvr132.076.267
RGBA4444.pvr155.906.383
RGBA5551.pvr157.559.150
RGB565.pvr.ccz189.076.883
RGBA5551.pvr.ccz206.933.150
RGBA4444.pvr.ccz208.405.133
RGB565.pvr.gz212.562.350
RGBA4444.pvr.gz226.271.433
RGBA5551.pvr.gz228.623.450
RGBA8888.pvr285.217.617
RGBA8888.pvr.ccz392.353.400
RGBA8888.pvr.gz420.908.317
RGB565.png697.689.750
RGBA4444.png702.992.150
RGBA5551.png704.371.517
RGBA8888.png740.525.900
RGBA8888.jpg4.250.968.067
RGBA4444.jpg4.320.874.967
RGBA5551.jpg4.336.442.100
RGB565.jpg4.377.636.567

Node Hierarchy (children)

The performance of functions that act on the node hierarchy (children list) depends heavily on the number of children.

NameEach (ns)
getChildByTag w/ 10 Nodes3.950
getChildByTag w/ 100 Nodes21.985
reorderChild w/ 10 Nodes22.472
reorderChild w/ 100 Nodes56.199
addChild with tag59.295
removeChildByTag92.136
getChildByTag w/ 500 Nodes157.449
reorderChild w/ 500 Nodes270.803
getChildByTag w/ 2,500 Nodes357.068
reorderChild w/ 2,500 Nodes1.422.534

Messaging / Function Calls

Low-level overhead for calling C++ functions respectively sending Objective-C messages in various ways.

NameEach (ns)
C++ virtual method call62
IMP-cached message send69
C++ cached virtual method call134
Objective-C message send166
NSInvocation message send2.000

Arithmetic Tests

Simple calculations done frequently in an app, using various data types.

NameEach (ns)
Integer multiplication19
Float multiplication41
Double multiplication45
Float division75
Float division with int conversion105
Double division115
Float square root144
Double division with int conversion147
Double square root186
Integer division367
Accelerometer Highpass filter422

Memory Tests

Allocating and releasing memory.

NameEach (ns)
16 byte memcpy153
16 byte malloc/free2.747
16MB malloc/free36.955
1MB memcpy10.162.236

File IO

NameEach (ns)
Read 16MB file856.130
Read 16-byte file858.290
Write 16MB file (atomic)2.214.739
Write 16-byte file4.794.658
Write 16-byte file (atomic)4.995.794
Write 16MB file8.658.106

Miscellaneous Tests

NameEach (ns)
Zero-second delayed perform335
pthread create/join806.348