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
// This program have to set node.js option --expose-gc | |
// ex) $ node --expose-gc string_serializer_benchmark.js | |
const strbase = "abあいAB##11"; | |
function bufferFromCommon(encode, join, repeat) { | |
const str = strbase.repeat(join); | |
console.time(`Buffer.from(${encode})`); | |
const newbuf = new ArrayBuffer(str.length * 3 * repeat); | |
const newview = new Uint8Array(newbuf); |
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 stringHash = require("string-hash"); | |
// 型識別子 | |
const typeToId = { | |
object: 1 * 16, | |
denseArray: 2 * 16, | |
sparseArray: 3 * 16, | |
string: 4 * 16, | |
uint4: 5 * 16, | |
number: 6 * 16, |
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
function _addIndex(character, lineNum, indexMap) { | |
let indexValue = indexMap.get(character); | |
if (!indexValue) { | |
indexValue = new Set(); | |
indexMap.set(character, indexValue); | |
} | |
indexValue.add(lineNum); | |
} | |
class PartMatchIndex { |
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 asyncHooks = require('async_hooks'); | |
const asyncMap = {} | |
asyncHooks.createHook({ | |
init(asyncId, type, triggerAsyncId) { | |
const parent = asyncHooks.executionAsyncId(); | |
// 親がスレッドに属していれば子も属す | |
if (asyncMap[parent]) { | |
asyncMap[asyncId] = asyncMap[parent]; |