mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
perf: remove transient strings to reduce memory
This commit is contained in:
+10
-6
@@ -28,10 +28,12 @@ function html () {
|
||||
for (let i = 0; i < SAMPLE_COUNT; i++) {
|
||||
templates.push(engine.parse(str))
|
||||
}
|
||||
global.gc()
|
||||
const diff1 = (getHeapStatistics().used_heap_size - base) / SAMPLE_COUNT
|
||||
console.log(`${h(str.length)} lorem-html before GC x ${h(diff1)}/tpl (${SAMPLE_COUNT} instances sampled)`)
|
||||
|
||||
const diff = (getHeapStatistics().used_heap_size - base) / SAMPLE_COUNT
|
||||
console.log(`${h(str.length)} HTML template x ${h(diff)}/instance (${SAMPLE_COUNT} instances sampled)`)
|
||||
global.gc()
|
||||
const diff2 = (getHeapStatistics().used_heap_size - base) / SAMPLE_COUNT
|
||||
console.log(`${h(str.length)} lorem-html after GC x ${h(diff2)}/tpl (${SAMPLE_COUNT} instances sampled)`)
|
||||
}
|
||||
|
||||
function todolist () {
|
||||
@@ -44,10 +46,12 @@ function todolist () {
|
||||
for (let i = 0; i < SAMPLE_COUNT; i++) {
|
||||
templates.push(engine.parse(str))
|
||||
}
|
||||
global.gc()
|
||||
const diff1 = (getHeapStatistics().used_heap_size - base) / SAMPLE_COUNT
|
||||
console.log(`${h(str.length)} todolist before GC x ${h(diff1)}/tpl (${SAMPLE_COUNT} instances sampled)`)
|
||||
|
||||
const diff = (getHeapStatistics().used_heap_size - base) / SAMPLE_COUNT
|
||||
console.log(`${h(str.length)} Todo template x ${h(diff)}/instance (${SAMPLE_COUNT} instances sampled)`)
|
||||
global.gc()
|
||||
const diff2 = (getHeapStatistics().used_heap_size - base) / SAMPLE_COUNT
|
||||
console.log(`${h(str.length)} todolist after GC x ${h(diff2)}/tpl (${SAMPLE_COUNT} instances sampled)`)
|
||||
}
|
||||
|
||||
function h (size) {
|
||||
|
||||
Reference in New Issue
Block a user