Skip to content

Latest commit

 

History

History
223 lines (184 loc) · 4.34 KB

README.md

File metadata and controls

223 lines (184 loc) · 4.34 KB

Data Structures Memory Usage in JavaScript

How to add stats

Stats for at least three types of data structures are required:

  • Indexed collection of values such as Array or Vector
  • Collection that maps keys to values such as Map or Record
  • Collection of unique values — Set
  1. See how test code is implemented in other languages
  2. Implement test code in lang X
  3. Put sources in a directory in src
  4. Write NPM build script using this template: "build:[lang]": "[build cmd]"
  5. Write NPM test script using this template: "run:[lang]": "node src/[lang]/test.js > out/[lang].json"
  6. Run test script
  7. Add results to README.md
  8. Submit a PR

JavaScript

{
  "empty object": 70.192,
  "empty array": 93.04,
  "empty map": 196.32,
  "empty set": 166.64,

  "10 item object": 143.552,
  "10 item array": 246.152,
  "10 item map": 882.304,
  "10 item set": 431.76,

  "100 item object": 6242.864,
  "100 item array": 1341.864,
  "100 item map": 6869.504,
  "100 item set": 2645.504,

  "1000 item object": 98685.52,
  "1000 item array": 11597.864,
  "1000 item map": 60768.392,
  "1000 item set": 20563.264
}

ImmutableJS

{
  "empty list": 19.904,
  "empty map": 23.16,
  "empty set": 23.192,

  "10 item list": 641.752,
  "10 item map": 1901.608,
  "10 item set": 1578.704,

  "100 item list": 2647.36,
  "100 item map": 17411.496,
  "100 item set": 15679.656,

  "1000 item list": 20485.224,
  "1000 item map": 182600.704,
  "1000 item set": 123834.648
}

ClojureScript

{
  "empty list": 8.936,
  "empty vector": 11.776,
  "empty map": 11.368,
  "empty set": 11.368,

  "10 item list": 783.92,
  "10 item vector": 286.744,
  "10 item map": 1366.72,
  "10 item set": 732.528,

  "100 item list": 7239.256,
  "100 item vector": 1600.8,
  "100 item map": 8896.968,
  "100 item set": 5402.552,

  "1000 item list": 72040.64,
  "1000 item vector": 11235.368,
  "1000 item map": 121328.16,
  "1000 item set": 123852.92
}

Kotlin

{
  "empty List": 117.872,
  "empty ArrayList": 107.24,
  "empty HashMap": 454.968,
  "empty HashSet": 497.112,

  "10 item List": 252,
  "10 item ArrayList": 262.624,
  "10 item HashMap": 1725.72,
  "10 item HashSet": 1072.216,

  "100 item List": 1165.448,
  "100 item ArrayList": 1166.744,
  "100 item HashMap": 20542.936,
  "100 item HashSet": 5630.728,

  "1000 item List": 9692.632,
  "1000 item ArrayList": 9695.568,
  "1000 item HashMap": 121960.52,
  "1000 item HashSet": 50820.536
}

GopherJS (Go)

{
  "empty array": 267,
  "empty map": 74,

  "10 item array": 385,
  "10 item map": 961,

  "100 item array": 781,
  "100 item map": 13474,

  "1000 item array": 4344,
  "1000 item map": 170444
}

RacketScript

{
  "empty list": 20.104,
  "empty vector": 138.48,
  "empty hash map": 235.8,

  "10 item list": 606.568,
  "10 item vector": 285.048,
  "10 item hash map": 1645.144,

  "100 item list": 5637.992,
  "100 item vector": 1234.384,
  "100 item hash map": 13579.56,

  "1000 item list": 55971,
  "1000 item vector": 10428.632,
  "1000 item hash map": 146484.752
}

Reason (BuckleScript)

{
  "empty List": 84,
  "empty Array": 145,
  "empty Set": 71,
  "empty Map": 71,
  "empty Hashtbl": 346,

  "10 item List": 720,
  "10 item Array": 207,
  "10 item Set": 975,
  "10 item Map": 1363,
  "10 item Hashtbl": 1443,

  "100 item List": 6480,
  "100 item Array": 927,
  "100 item Set": 8082,
  "100 item Map": 12081,
  "100 item Hashtbl": 11165,

  "1000 item List": 64073,
  "1000 item Array": 8122,
  "1000 item Set": 80404,
  "1000 item Map": 120077,
  "1000 item Hashtbl": 108343
}

Elm

{
  "empty list": 43.776,
  "empty array": 11.456,
  "empty dict": 11.368,
  "empty set": 11.424,

  "10 item list": 524.696,
  "10 item array": 208.288,
  "10 item dict": 1076.36,
  "10 item set": 1114.608,

  "100 item list": 4851.144,
  "100 item array": 1267.408,
  "100 item dict": 10436.36,
  "100 item set": 10475.792,

  "1000 item list": 48046.928,
  "1000 item array": 11220.536,
  "1000 item dict": 104329.2,
  "1000 item set": 104248.064
}