-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #834 from Stuk/benchmark
Add benchmark/performance tests
- Loading branch information
Showing
8 changed files
with
191 additions
and
34 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,8 @@ | ||
"use strict"; | ||
|
||
module.exports = { | ||
globals: { | ||
// Added by index.html and node.js | ||
Benchmark: false, | ||
}, | ||
}; |
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,39 @@ | ||
"use strict"; | ||
|
||
(function (root, factory) { | ||
if (typeof module === "object" && module.exports) { | ||
module.exports = factory(); | ||
} else { | ||
root.benchmark = factory(); | ||
} | ||
}(typeof self !== "undefined" ? self : this, function () { | ||
return function (type) { | ||
return new Promise(resolve => { | ||
const suite = new Benchmark.Suite(); | ||
|
||
suite | ||
.add(`${type} generateAsync`, { | ||
defer: true, | ||
async fn(deferred) { | ||
const zip = new JSZip(); | ||
|
||
for (let i = 0; i < 50; i++) { | ||
zip.file("file_" + i, "R0lGODdhBQAFAIACAAAAAP/eACwAAAAABQAFAAACCIwPkWerClIBADs=", { base64: true, date: new Date(1234123491011) }); | ||
} | ||
|
||
await zip.generateAsync({ type }); | ||
deferred.resolve(); | ||
} | ||
}) | ||
.on("cycle", event => { | ||
// Output benchmark result by converting benchmark result to string | ||
console.log(String(event.target)); | ||
}) | ||
.on("complete", () => { | ||
console.log("Benchmark complete"); | ||
resolve(); | ||
}) | ||
.run({ "async": true }); | ||
}); | ||
}; | ||
})); |
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 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | ||
<title>JSZip Benchmark</title> | ||
</head> | ||
<body> | ||
<script src="../../node_modules/benchmark/node_modules/lodash/lodash.js"></script> | ||
<script src="../../node_modules/benchmark/benchmark.js"></script> | ||
<script src="../../dist/jszip.js"></script> | ||
<script src="./benchmark.js"></script> | ||
<script> | ||
benchmark("arraybuffer"); | ||
</script> | ||
</body> | ||
</html> |
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,7 @@ | ||
"use strict"; | ||
|
||
globalThis.Benchmark = require("benchmark"); | ||
globalThis.JSZip = require("../../lib/index"); | ||
|
||
const benchmark = require("./benchmark"); | ||
benchmark("nodebuffer"); |
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