-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/optimize collections for json (#38)
* Optimize dict for JSON * Refactor grid * Move column caching into HGrid implementation * Refactor grid * Add grid stores * Add refreshColumns to grid * Manually refresh columns in a grid * Remove dict validate * Tweak grid toZinc * Remove observable hack * Add tests for grid json encoding * Add lazy grid json store * Tweak index * Add toJSONString to all hval types * Ensure dict lazily decodes gradually * Add JSON string store implementations for grid and dict * Encode to JSON byte buffer * Add JSON byte buffer support to grid and dict store * Add Uint8Array buffer stores * Move list * Make symbols readonly * Add list store * Add list JSON handling * Add list JSON store * Optimize JSON encoding of a grid * Tweak JSON list encoding * Ensure dict json store saves on memory * Tweak position of dict store symbol * Refactor grid data handling * Tweak list json save memory * Add list JSON string store * Add list byte buffer support * Add performance test * Remove unnecessary toJSON * Fix test comments
- Loading branch information
Showing
99 changed files
with
4,594 additions
and
1,084 deletions.
There are no files selected for viewing
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright (c) 2025, J2 Innovations. All Rights Reserved | ||
*/ | ||
|
||
const { readFile } = require('fs/promises') | ||
const { HGrid, GridJsonStore } = require('../dist/index.es') | ||
|
||
async function run() { | ||
const file = await readFile('./spec/files/skySparkDefs.json', 'utf-8') | ||
const json = JSON.parse(file) | ||
|
||
function doGrid(grid) { | ||
grid.meta.set('foo', 'bar') | ||
|
||
grid.toJSON() | ||
} | ||
|
||
function testOld() { | ||
const grid = HGrid.make({ | ||
meta: json.meta, | ||
rows: json.rows, | ||
columns: json.cols, | ||
}) | ||
doGrid(grid) | ||
} | ||
|
||
function testNew() { | ||
const grid = new HGrid(new GridJsonStore(json)) | ||
doGrid(grid) | ||
} | ||
|
||
console.log('Priming (triggers JIT)...') | ||
for (let i = 0; i < 10_000; ++i) { | ||
testOld() | ||
testNew() | ||
} | ||
|
||
console.log('Running tests...') | ||
{ | ||
const t0 = performance.now() | ||
testOld() | ||
const t1 = performance.now() | ||
console.log('Performance test old way: ' + (t1 - t0) + ' milliseconds.') | ||
} | ||
|
||
{ | ||
let t0 = performance.now() | ||
testNew() | ||
const t1 = performance.now() | ||
console.log('Performance test new way: ' + (t1 - t0) + ' milliseconds.') | ||
} | ||
} | ||
|
||
run() |
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 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 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 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 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 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 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 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 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
Oops, something went wrong.