Created
November 29, 2017 15:08
-
-
Save ylt6/8185998d03e80f0d8c0d6fcd91c12662 to your computer and use it in GitHub Desktop.
check_tie_memory_usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const createTrie = require('autosuggest-trie'); | |
const sizeOf = require('object-sizeof'); | |
// sample data | |
const locations = [ | |
{ | |
id: 1, | |
name: 'East Richmond 1234 VIC', | |
population: 10000 | |
}, | |
{ | |
id: 2, | |
name: 'East Eagle 1235 VIC', | |
population: 5000 | |
}, | |
{ | |
id: 3, | |
name: 'Richmond West 5678 VIC', | |
population: 4000 | |
}, | |
{ | |
id: 4, | |
name: 'Cheltenham 3192 Melbourne VIC', | |
population: 7000 | |
}, | |
{ | |
id: 5, | |
name: 'Richmond 6776 VIC', | |
population: 3000 | |
} | |
]; | |
const trie = createTrie(locations, 'name'); | |
const concatedString = locations | |
.map(e => e.name) | |
.reduce((acc, cur) => acc + cur, ''); | |
console.log(`concated string: ${concatedString}`); | |
console.log(`bytes of string: ${sizeOf(concatedString)}`); | |
console.log(`bytes of trie: ${sizeOf(trie.trie)}`); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
console output: