Skip to content

Commit

Permalink
chore: Update example (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
rrr523 authored Dec 18, 2023
1 parent b44c413 commit 6771bed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions packages/reed-solomon/examples/folder.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,23 @@ const folderPath = './dist';

(async () => {
async function traverse(currentPath) {
const start = Date.now();
console.time('total');
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();
console.time('file', file);
const fileBuffer = await fs.readFile(filePath);
const res = await rs.encodeInWorker(__filename, Uint8Array.from(fileBuffer));
console.log('res', file, Date.now() - start, res);
console.timeEnd('file');
console.log(file, 'res: ', res);
}

console.log('files count: ', files.length);
console.log('total cost time: ', Date.now() - start);
console.timeEnd('total');
}

await traverse(folderPath);
Expand Down
4 changes: 2 additions & 2 deletions packages/reed-solomon/examples/singlefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const rs = new NodeAdapterReedSolomon();

// single file
(async () => {
const start = Date.now();
console.time('cost');
const res = await rs.encodeInWorker(__filename, Uint8Array.from(fileBuffer));
console.log('res', res);
console.log('cost time', Date.now() - start);
console.timeEnd('cost');
})();

0 comments on commit 6771bed

Please sign in to comment.