Skip to content

Commit

Permalink
feat: benchmark different sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomura committed Feb 3, 2024
1 parent 088b887 commit 716de9e
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ Each `ImageMarker` object in the output array adheres to the following structure
Performance is a key focus of `jay-peg``. In a benchmark test using a 2448×3264, 2.2MB JPEG image, the decoding speed was measured as follows:

```
Benchmarked: decode: x 2,772 ops/sec ±0.23% (98 runs sampled)
Benchmarked: small: x 11,597 ops/sec ±0.60% (95 runs sampled)
Benchmarked: medium: x 11,219 ops/sec ±0.20% (98 runs sampled)
Benchmarked: large: x 7,744 ops/sec ±0.27% (100 runs sampled)
Benchmarked: huge: x 2,019 ops/sec ±0.36% (96 runs sampled)
```

It's worth noting that the performance is significantly improved on smaller and simpler images.
Expand Down
Binary file removed benchmark/daft-punk.jpeg
Binary file not shown.
Binary file added benchmark/huge.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions benchmark/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ import JPEG from "../src/index.js";
const suite = new Benchmark.Suite();

const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
const buffer = fs.readFileSync(`${__dirname}/daft-punk.jpeg`);
const small = fs.readFileSync(`${__dirname}/small.jpg`);
const medium = fs.readFileSync(`${__dirname}/medium.jpg`);
const large = fs.readFileSync(`${__dirname}/large.jpg`);
const huge = fs.readFileSync(`${__dirname}/huge.jpg`);

suite.add("decode".magenta + ": ".green, () => JPEG.decode(buffer));
suite.add("small".magenta + ": ".green, () => JPEG.decode(small));
suite.add("medium".magenta + ": ".green, () => JPEG.decode(medium));
suite.add("large".magenta + ": ".green, () => JPEG.decode(large));
suite.add("huge".magenta + ": ".green, () => JPEG.decode(huge));

console.log("=== TESTS OPS/SECOND ===".magenta);

Expand Down
Binary file added benchmark/large.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added benchmark/medium.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added benchmark/small.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 716de9e

Please sign in to comment.