Skip to content

Commit 4cf98b5

Browse files
committed
Add logging for sizes of large data buffers in tests
1 parent 0ff9f19 commit 4cf98b5

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

test/test.js

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ var largeOld = crypto.randomBytes(1024 * 100);
3535
var largeNew = Buffer.concat([Buffer.from("header"), largeOld, Buffer.from("footer")]);
3636
var largeDiff = hdiffpatch.diff(largeOld, largeNew);
3737
var largePatched = hdiffpatch.patch(largeOld, largeDiff);
38+
console.log(" largeOld size:", largeOld.length);
39+
console.log(" largeNew size:", largeNew.length);
40+
console.log(" largeDiff size:", largeDiff.length);
3841
assert.deepStrictEqual(largePatched, largeNew);
3942
console.log(" ✓ Large data sync works");
4043

@@ -46,23 +49,3 @@ var uint8Patched = hdiffpatch.patch(uint8Old, uint8Diff);
4649
assert.deepStrictEqual(Buffer.from(uint8Patched), newData);
4750
console.log(" ✓ Uint8Array works");
4851

49-
console.log("\nTest 5: Async diff + patch (Promise)...");
50-
(async () => {
51-
var asyncOld = crypto.randomBytes(1024 * 500); // 500KB
52-
var asyncNew = Buffer.concat([Buffer.from("async_"), asyncOld.slice(1000)]);
53-
54-
console.log(" Starting async diff (500KB)...");
55-
var startDiff = Date.now();
56-
var asyncDiffResult = await hdiffpatch.diffAsync(asyncOld, asyncNew);
57-
console.log(" Async diff took:", Date.now() - startDiff, "ms");
58-
59-
console.log(" Starting async patch...");
60-
var startPatch = Date.now();
61-
var asyncPatched = await hdiffpatch.patchAsync(asyncOld, asyncDiffResult);
62-
console.log(" Async patch took:", Date.now() - startPatch, "ms");
63-
64-
assert.deepStrictEqual(asyncPatched, asyncNew);
65-
console.log(" ✓ Async diff + patch works");
66-
67-
console.log("\n✅ All tests passed!");
68-
})();

0 commit comments

Comments
 (0)