-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
52 additions
and
13 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,30 @@ | ||
/* eslint-disable */ | ||
const fs = require('node:fs/promises'); | ||
const path = require('node:path'); | ||
const { NodeAdapterReedSolomon } = require('../dist/node.adapter'); | ||
|
||
const rs = new NodeAdapterReedSolomon(); | ||
const folderPath = './dist'; | ||
|
||
(async () => { | ||
async function traverse(currentPath) { | ||
const start = Date.now(); | ||
const files = await fs.readdir(currentPath); | ||
|
||
for (let i = 0; i < files.length; i++) { | ||
const file = files[i]; | ||
const filePath = path.join(currentPath, file); | ||
const stat = await fs.stat(filePath); | ||
|
||
const start = Date.now(); | ||
const fileBuffer = await fs.readFile(filePath); | ||
const res = await rs.encodeInWorker(__filename, Uint8Array.from(fileBuffer)); | ||
console.log('res', file, Date.now() - start, res); | ||
} | ||
|
||
console.log('files count: ', files.length); | ||
console.log('total cost time: ', Date.now() - start); | ||
} | ||
|
||
await traverse(folderPath); | ||
})(); |
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,16 @@ | ||
/* eslint-disable */ | ||
const fs = require('node:fs'); | ||
const path = require('node:path'); | ||
const { NodeAdapterReedSolomon } = require('../dist/node.adapter'); | ||
|
||
const fileBuffer = fs.readFileSync('./README.md'); | ||
|
||
const rs = new NodeAdapterReedSolomon(); | ||
|
||
// single file | ||
(async () => { | ||
const start = Date.now(); | ||
const res = await rs.encodeInWorker(__filename, Uint8Array.from(fileBuffer)); | ||
console.log('res', res); | ||
console.log('cost time', Date.now() - start); | ||
})(); |