{"id":15350611,"url":"https://github.com/gaul/java-collection-overhead","last_synced_at":"2025-04-15T04:20:43.352Z","repository":{"id":144978642,"uuid":"131113660","full_name":"gaul/java-collection-overhead","owner":"gaul","description":"Demonstrate overheads for various Java Collection implementations.","archived":false,"fork":false,"pushed_at":"2018-10-01T22:08:50.000Z","size":20,"stargazers_count":18,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-13T19:23:21.051Z","etag":null,"topics":["collection","java"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gaul.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-26T07:00:39.000Z","updated_at":"2023-03-01T12:34:10.000Z","dependencies_parsed_at":"2023-04-11T01:31:05.158Z","dependency_job_id":null,"html_url":"https://github.com/gaul/java-collection-overhead","commit_stats":{"total_commits":11,"total_committers":1,"mean_commits":11.0,"dds":0.0,"last_synced_commit":"a4be8ba081702cafb3f385002187aa8bdae2da2e"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaul%2Fjava-collection-overhead","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaul%2Fjava-collection-overhead/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaul%2Fjava-collection-overhead/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaul%2Fjava-collection-overhead/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gaul","download_url":"https://codeload.github.com/gaul/java-collection-overhead/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249004367,"owners_count":21196863,"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":["collection","java"],"created_at":"2024-10-01T11:58:51.517Z","updated_at":"2025-04-15T04:20:43.331Z","avatar_url":"https://github.com/gaul.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Java Collection Overhead\n\nDemonstrate overheads for various Java Collection implementations.  This\nmeasures storing `int` data, excluding the cost of boxed `Integer`s.\nThis compares built-in Java, [fastutil](http://fastutil.di.unimi.it/),\n[Guava](https://github.com/google/guava), and\n[Trove](https://bitbucket.org/trove4j/trove/) collections.\nTested with JDK 8 on x86-64 Linux with\n[compressed Oops](https://docs.oracle.com/javase/8/docs/technotes/guides/vm/performance-enhancements-7.html#compressedOop)\n(default).\n\n## Results\n\nMeasure per-entry overhead by creating a single large collection.  Measure\nper-instance overhead by creating many small collections with a single element.\n*This over-reports per-instance overhead by 4 bytes due to\n`Collection\u003cCollection\u003e`*\n\n| Collection               | Per-entry\u003cbr /\u003eOverhead (bytes) | Per-instance\u003cbr /\u003eOverhead (bytes) |\n| ------------------------ | ---:| ---:|\n| **List**                 |     |     |\n| ArrayList                |   4 |  52 |\n| ImmutableList            |   4 |  20 |\n| LinkedList               |  24 |  60 |\n| TIntArrayList            |   4 |  52 |\n| TIntLinkedList           |  24 |  60 |\n|                          |     |     |\n| **Map**                  |     |     |\n| Cache                    |  56 | 916 |\n| ConcurrentHashMap        |  40 | 180 |\n| ConcurrentSkipListMap    |  36 | 145 |\n| EnumMap                  | n/a | 124 |\n| HashMap                  |  40 | 108 |\n| ImmutableMap             |  32 |  44 |\n| ImmutableRangeMap        |  64 | 116 |\n| ImmutableSortedMap       |   8 | 108 |\n| Int2IntAVLTreeMap        |  32 | 164 |\n| Int2IntLinkedOpenHashMap |  32 | 188 |\n| Int2IntOpenHashMap       |  16 | 132 |\n| Int2IntRBTreeMap         |  32 | 452 |\n| LinkedHashMap            |  48 | 124 |\n| LongLongHashMap          |  32 | 116 |\n| MapMaker                 |  40 | 244 |\n| TIntIntHashMap           |  18 | 156 |\n| TreeMap                  |  40 |  92 |\n| TreeRangeMap             | 120 | 188 |\n|                          |     |     |\n| **Multiset**             |     |     |\n| ConcurrentHashMultiset   |  56 | 220 |\n| HashMultiset             |  56 | 156 |\n| ImmutableMultiset        |  32 | 116 |\n| LinkedHashMultiset       |  64 | 172 |\n| TreeMultiset             |  56 | 212 |\n|                          |     |     |\n| **Queue**                |     |     |\n| ArrayDeque               |   8 | 108 |\n| ConcurrentLinkedDeque    |  24 |  76 |\n| PriorityQueue            |   4 |  60 |\n|                          |     |     |\n| **Set**                  |     |     |\n| ConcurrentSkipListSet    |  36 | 161 |\n| EnumSet                  | n/a |  36 |\n| HashSet                  |  40 | 124 |\n| ImmutableRangeSet        |  60 | 100 |\n| ImmutableSet             |  12 |  28 |\n| ImmutableSortedSet       |   4 |  52 |\n| IntAVLTreeSet            |  32 | 140 |\n| IntLinkedOpenHashSet     |  24 | 132 |\n| IntOpenHashSet           |   8 |  84 |\n| IntRBTreeSet             |  32 | 436 |\n| LinkedHashSet            |  48 | 140 |\n| LongHashSet              |  16 |  76 |\n| TIntHashSet              |   8 | 116 |\n| TreeRangeSet             |  96 | 180 |\n| TreeSet                  |  40 | 108 |\n\nCollected via:\n\n```bash\ntarget/java-collection-overhead --list | grep -v Enum | while read c; do target/java-collection-overhead $c $((8 * 1024 * 1024)) 1 || break; done\ntarget/java-collection-overhead --list | while read c; do target/java-collection-overhead $c 1 $((1024 * 1024)) || break; done\n```\n\n## References\n\n* https://github.com/DimitrisAndreou/memory-measurer/blob/master/ElementCostInDataStructures.txt\n* https://www.ibm.com/developerworks/java/library/j-codetoheap/\n\n## License\n\nCopyright (C) 2018 Andrew Gaul\n\nLicensed under the Apache License, Version 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaul%2Fjava-collection-overhead","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgaul%2Fjava-collection-overhead","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaul%2Fjava-collection-overhead/lists"}