{"id":19033183,"url":"https://github.com/mrsuh/php-collections-comparison","last_synced_at":"2026-05-04T15:30:20.801Z","repository":{"id":82961436,"uuid":"471023220","full_name":"mrsuh/php-collections-comparison","owner":"mrsuh","description":null,"archived":false,"fork":false,"pushed_at":"2022-03-22T08:27:12.000Z","size":21,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-02T04:41:21.195Z","etag":null,"topics":["php-generics"],"latest_commit_sha":null,"homepage":"https://mrsuh.com/articles/2022/comparing-php-collections/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrsuh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-17T14:27:47.000Z","updated_at":"2024-12-01T18:05:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"109ec6ef-6f41-4691-9360-dd664d44a17b","html_url":"https://github.com/mrsuh/php-collections-comparison","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrsuh%2Fphp-collections-comparison","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrsuh%2Fphp-collections-comparison/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrsuh%2Fphp-collections-comparison/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrsuh%2Fphp-collections-comparison/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrsuh","download_url":"https://codeload.github.com/mrsuh/php-collections-comparison/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240086466,"owners_count":19745826,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["php-generics"],"created_at":"2024-11-08T21:36:03.928Z","updated_at":"2026-05-04T15:30:18.270Z","avatar_url":"https://github.com/mrsuh.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP collections comparison\n\n### Memory performance\n\n#### Items in collection: 0\n| type                  | var_class_sizeof(bytes) | var_sizeof(bytes) | memory_get_usage(bytes) |\n|-----------------------|-------------------------|-------------------|-------------------------|\n| array(count: 0)       | 0                       | 336               | 0                       |\n| psalm(count: 0)       | 1,510                   | 544               | 240                     |\n| monomorphic(count: 0) | 1,528                   | 544               | 240                     |\n| type-erased(count: 0) | 1,512                   | 544               | 240                     |\n\n#### Items in collection: 100\n| type                    | var_class_sizeof(bytes) | var_sizeof(bytes) | memory_get_usage(bytes) |\n|-------------------------|-------------------------|-------------------|-------------------------|\n| array(count: 100)       | 0                       | 7,728             | 12,248                  |\n| psalm(count: 100)       | 1,510                   | 7,936             | 12,432                  |\n| monomorphic(count: 100) | 1,528                   | 7,936             | 12,432                  |\n| type-erased(count: 100) | 1,512                   | 7,936             | 12,432                  |\n\n#### Items in collection: 1000\n| type                     | var_class_sizeof(bytes) | var_sizeof(bytes) | memory_get_usage(bytes) |\n|--------------------------|-------------------------|-------------------|-------------------------|\n| array(count: 1000)       | 0                       | 72,464            | 76,920                  |\n| psalm(count: 1000)       | 1,510                   | 72,672            | 77,104                  |\n| monomorphic(count: 1000) | 1,528                   | 72,672            | 77,104                  |\n| type-erased(count: 1000) | 1,512                   | 72,672            | 77,104                  |\n\n#### Items in collection: 10000\n| type                      | var_class_sizeof(bytes) | var_sizeof(bytes) | memory_get_usage(bytes) |\n|---------------------------|-------------------------|-------------------|-------------------------|\n| array(count: 10000)       | 0                       | 822,224           | 1,051,320               |\n| psalm(count: 10000)       | 1,510                   | 822,432           | 1,051,560               |\n| monomorphic(count: 10000) | 1,528                   | 822,432           | 1,051,560               |\n| type-erased(count: 10000) | 1,512                   | 822,432           | 1,051,560               |\n\n### Speed performance\n\n```bash\nPHPBench (1.2.3) running benchmarks...\nwith configuration file: /app/phpbench.json\nwith PHP version 8.1.3, xdebug ❌, opcache ❌\n\n\\App\\Tests\\TypHintBench\n\n    benchWithoutType........................R1 I6 - Mo240.713μs (±0.47%)\n    benchWithArrayType......................R1 I70 - Mo247.663μs (±0.45%)\n    benchWithMixedType......................R2 I59 - Mo249.293μs (±0.54%)\n    benchWithClassType......................R1 I26 - Mo306.533μs (±0.48%)\n\nSubjects: 4, Assertions: 0, Failures: 0, Errors: 0\n+--------------+--------------------+-----+------+-----+-----------+-----------+--------+\n| benchmark    | subject            | set | revs | its | mem_peak  | mode      | rstdev |\n+--------------+--------------------+-----+------+-----+-----------+-----------+--------+\n| TypHintBench | benchWithoutType   |     | 1000 | 100 | 674.272kb | 240.713μs | ±0.47% |\n| TypHintBench | benchWithArrayType |     | 1000 | 100 | 674.272kb | 247.663μs | ±0.45% |\n| TypHintBench | benchWithMixedType |     | 1000 | 100 | 674.272kb | 249.293μs | ±0.54% |\n| TypHintBench | benchWithClassType |     | 1000 | 100 | 674.272kb | 306.533μs | ±0.48% |\n+--------------+--------------------+-----+------+-----+-----------+-----------+--------+\n```\n\n### How to reproduce\n```bash\ngit clone git@github.com:mrsuh/php-collections-comparison.git \u0026\u0026 cd php-collections-comparison\ndocker build -t php-collections-comparison-image .\ndocker run -it --rm php-collections-comparison-image php bin/memory-test.php\ndocker run -it --rm php-collections-comparison-image php vendor/bin/phpbench run tests --report=aggregate\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrsuh%2Fphp-collections-comparison","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrsuh%2Fphp-collections-comparison","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrsuh%2Fphp-collections-comparison/lists"}