diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..b943dbc --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "deno.enable": true +} \ No newline at end of file diff --git a/dev.ts b/dev.ts index 8885505..61d40ba 100644 --- a/dev.ts +++ b/dev.ts @@ -6,7 +6,7 @@ const testPath = "./test.txt"; const writeResult = await sequentialWriteTest( { filePath: testPath, - sizeInMB: 1000, + sizeInMB: 200, rounds: 10, bufferSizeMB: 1, keepTheFile: true, diff --git a/speedtest/lib.ts b/speedtest/lib.ts index 803b1c4..78182e6 100644 --- a/speedtest/lib.ts +++ b/speedtest/lib.ts @@ -65,14 +65,16 @@ export async function sequentialReadTest( ): Promise { const { filePath, rounds, deleteAfter } = options; const file = await Deno.open(filePath, { read: true }); - const buffer = new Uint8Array(oneMB); // 1MB buffer + const reader = file.readable.getReader(); const start = performance.now(); let totalMB = 0; - while ((await file.read(buffer)) !== null) { - totalMB += 1; + + let readResult; + while (!(readResult = await reader.read()).done) { + totalMB += readResult.value.length / oneMB; } const totalDuration = (performance.now() - start) / 1000; - file.close(); + // file.close(); if (options.deleteAfter) { Deno.removeSync(filePath); } diff --git a/src/lib/store.ts b/src/lib/store.ts index 0c0acf9..31ef91f 100644 --- a/src/lib/store.ts +++ b/src/lib/store.ts @@ -1,4 +1,4 @@ import { writable } from "svelte/store"; export const stress = writable(1); -export const targetDir = writable(undefined); +export const targetDir = writable("/Users/kunkun/Desktop");