{"id":26172124,"url":"https://github.com/tapwork/enumeration-comparison","last_synced_at":"2026-04-13T07:37:17.985Z","repository":{"id":27839025,"uuid":"31329086","full_name":"tapwork/enumeration-comparison","owner":"tapwork","description":"Objective C enumeration comparison","archived":false,"fork":false,"pushed_at":"2015-02-25T20:08:53.000Z","size":148,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-26T19:37:07.125Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tapwork.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-25T18:28:51.000Z","updated_at":"2015-02-25T20:08:53.000Z","dependencies_parsed_at":"2022-09-03T13:24:46.247Z","dependency_job_id":null,"html_url":"https://github.com/tapwork/enumeration-comparison","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tapwork/enumeration-comparison","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tapwork%2Fenumeration-comparison","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tapwork%2Fenumeration-comparison/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tapwork%2Fenumeration-comparison/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tapwork%2Fenumeration-comparison/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tapwork","download_url":"https://codeload.github.com/tapwork/enumeration-comparison/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tapwork%2Fenumeration-comparison/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31744404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T06:26:45.479Z","status":"ssl_error","status_checked_at":"2026-04-13T06:26:44.645Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-11T19:53:19.961Z","updated_at":"2026-04-13T07:37:17.957Z","avatar_url":"https://github.com/tapwork.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Objective C Enumeration Performance Comparison\nThis little demo compares the performance and memory footprint of following enumerations\n#### For loop\n```objc\nfor (int i = 0; i \u003c [stringValues count]; i++) { ... }\n  ```\n#### Fast enumeration\n```objc\nfor (NSString *string in stringValues) { ... }\n  ```\n\n#### enumerateObjectsUsingBlock\n```objc\n[stringValues enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { ... }];\n```\n\n#### objectEnumerator\n```objc\nNSEnumerator *enumerator = [stringValues objectEnumerator];\nid obj = nil;\nwhile (obj = [enumerator nextObject]) { ... };\n```\n\n#### Concurrent enumerateObjectsUsingBlock\n```objc\n[stringValues enumerateObjectsWithOptions:NSEnumerationConcurrent usingBlock:^(id obj, NSUInteger idx, BOOL *stop) { ... }];\n```\n\n#### MakeObjectsPerformSelector\n```objc\n[stringValues makeObjectsPerformSelector:@selector(uppercaseString)];\n```\n\n## Results\nOn my iPhone 6 I have the following setup for the tests.\n* 3 Mio iterations sending the message `uppercaseString`\n* Airplane mode\n* All apps terminated\n* Batterie: 100% and powered by USB\n\n#### Comparison in seconds\n\n| Loop type                  |    Run 1     |    Run 2         |   Run 3                  |\n|----------------------------|--------------|------------------|--------------------------|\n| For Loop                   | 2.545244     |   2.543291       | 2.545505                 |\n| Fast Enumeration           | 2.282996     |   2.279801       | 2.266571                 |\n| enumerateObjectsUsingBlock | 2.466647     |   2.440913       |  2.440402                |\n| objectEnumerator           | 2.536801     |   2.523067       |  2.508857                |\n| Concurrent                 | 1.488604     |   1.505069       |  1.475192                |\n| MakeObjectsPerformSelector | 2.951380     |   2.847308       |   2.861406               |\n\n\nNo suprise, the concurrent one wins, because it leverages the two cores of the Apple A8.\nBut I noticed an even one more interesting side effect : **The Memory footprint** that bas been created after the test.\n\n#### Comparison in memory\n| Loop type                  | Peak (MB) | After task (MB) |\n|----------------------------|-----------|----------------|\n| For Loop                   | 28.7       |   3.5         |\n| Fast Enumeration           | 28.8       |   3.5         |\n| enumerateObjectsUsingBlock | 28.8       |   3.6         |\n| objectEnumerator           | 28.8       |   3.3         |\n| Concurrent                 | 28.7       |   3.6         |\n| MakeObjectsPerformSelector | **291**    |  **278**     |\n\nWhat is going on in `makeObjectsPerformSelector:`? \u003cbr\u003e\nWhy is the memory footprint increasing so dramatically? \u003cbr\u003e\nWhy stays the memory really high after the iteration has been completed?\n\n\n## Contact\n[Christian Menschel](http://github.com/tapwork) ([@cmenschel](https://twitter.com/cmenschel))\n\n# License\n[MIT](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftapwork%2Fenumeration-comparison","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftapwork%2Fenumeration-comparison","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftapwork%2Fenumeration-comparison/lists"}