Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: main.js

Issue 29794564: [proof-of-concept] Compact trie (Closed)
Patch Set: Created May 30, 2018, 11:12 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« CompactTrie.cpp ('K') | « CompactTrie.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 let readline = require("readline");
2
3 let Module = require("./CompactTrie");
4
5 let rl = readline.createInterface({input: process.stdin, terminal: false});
6
7 let lineNumber = 0;
8 let trie = null;
9
10 function printMemoryUsage()
11 {
12 let m = process.memoryUsage();
13 for (let k in m)
14 console.log(k + ": " +
15 String(m[k] / 1024 / 1024).replace(/(\d\.\d\d).*/, "$1"));
16 }
17
18 rl.on("line", line =>
19 {
20 if (!trie)
21 trie = new Module.CompactTrie();
22
23 let node = trie.set(new Buffer(line), ++lineNumber);
24 if (trie.get(new Buffer(line)) != lineNumber)
25 throw "!";
26 console.log(Buffer.from(node.bytes(), "ascii").toString());
27 });
28
29 rl.on("close", () =>
30 {
31 global.gc();
32 printMemoryUsage();
33
34 trie.delete();
35 trie = null;
36 });
OLDNEW
« CompactTrie.cpp ('K') | « CompactTrie.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld