Skip to content

Commit

Permalink
Merge pull request #3 from liqueurdetoile/dev1.0.0
Browse files Browse the repository at this point in the history
feat: Release 1.0.0
  • Loading branch information
liqueurdetoile authored Sep 12, 2019
2 parents 017257a + adb5d28 commit bd97b69
Show file tree
Hide file tree
Showing 45 changed files with 39,890 additions and 13,495 deletions.
14 changes: 11 additions & 3 deletions .config/karma.benchmark.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Karma configuration

var webpackConfig = require('./webpack/build.js');
var webpackConfig = require('./webpack/bench.js');

module.exports = function (config) {
config.set({
Expand All @@ -24,13 +24,17 @@ module.exports = function (config) {
'benchmarks/index.js': ['webpack']
},

reporters: ['benchmark'],
reporters: ['benchmark', 'benchmark-json'],

benchmarkReporter: {
showBrowser: true,
terminalWidth: 90
},

benchmarkJsonReporter: {
pathToJson: 'benchmarks/results.json'
},

port: 9876,

colors: true,
Expand All @@ -43,6 +47,10 @@ module.exports = function (config) {

singleRun: true,

concurrency: 1
concurrency: 1,

browserDisconnectTimeout: 60000,

browserNoActivityTimeout : 600000
});
};
18 changes: 13 additions & 5 deletions .config/webpack/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ function resolve(dir) {
}

module.exports = {
entry: {
'blob-compare': './src/index.js'
},
entry: './src/index.js',
output: {
jsonpFunction: 'blob-compare',
library: 'blobCompare',
libraryTarget: "umd"
},
module: {
Expand All @@ -20,6 +18,16 @@ module.exports = {
test: /(\.js)$/,
loader: 'babel-loader',
exclude: /node_modules|tests|benchmarks/
},
{
test: /(\.worker.js)$/,
loader: 'worker-loader',
options: { inline: true, fallback: false },
exclude: /node_modules/
},
{
test: /\.(bmp|png|jpe?g|txt)$/i,
loader: 'arraybuffer-loader',
}
]
},
Expand All @@ -30,7 +38,7 @@ module.exports = {
],
extensions: ['.js'],
alias: {
'@': resolve('../src')
'@': path.resolve('./src')
}
}
};
13 changes: 13 additions & 0 deletions .config/webpack/bench.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const webpack = require('webpack');
const path = require('path');
const merge = require('webpack-merge');
const base = require('./base.js');

module.exports = merge(base, {
devtool: false,
performance: {
hints: false // Only here to disable large assets message when doing benchmark
},
mode: 'production',
watch: false
});
8 changes: 2 additions & 6 deletions .config/webpack/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@ const webpack = require('webpack');
const path = require('path');
const merge = require('webpack-merge');
const base = require('./base.js');
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;

module.exports = merge(base, {
devtool: false,
mode: 'production',
output: {
path: path.resolve('./dist'),
filename: 'index.min.js',
library: 'blobCompare'
filename: 'index.min.js'
},
plugins: [
new webpack.IgnorePlugin(/fixtures/),
new webpack.optimize.ModuleConcatenationPlugin(),
// new BundleAnalyzerPlugin()
new webpack.optimize.ModuleConcatenationPlugin()
]
});
32 changes: 32 additions & 0 deletions benchmarks/00.converters.bench.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import blobCompare from '@';
import blobs from '../fixtures';

let dataset = new Map();

dataset.set('empty', blobs.empty());
dataset.set('small', blobs.create([['a', Math.pow(2, 16)]]));
dataset.set('medium', blobs.get('mid.jpg'));

for (let [name, blob] of dataset) {
suite(`Converters benchmark with ${name} blob (${blob.size} bytes)`, () => {
benchmark(`Binary String (worker)`, async () => {
return await blobCompare.toBinaryString(blob);
}, {maxTime: 1});

benchmark(`ArrayBuffer (worker)`, async () => {
return await blobCompare.toArrayBuffer(blob);
}, {maxTime: 1});

benchmark(`Binary String (main)`, async () => {
return await blobCompare.toBinaryString(blob, false, false);
}, {maxTime: 1});

benchmark(`ArrayBuffer (main)`, async () => {
return await blobCompare.toArrayBuffer(blob, false, false);
}, {maxTime: 1});
}, {
onComplete() {
dataset.delete(name);
}
});
}
30 changes: 30 additions & 0 deletions benchmarks/01.comparators.bench.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import blobCompare from '@';
import blobs from '../fixtures';

let dataset = new Map();

dataset.set('empty', blobs.buffer(0));
dataset.set('small', blobs.buffer(Math.pow(2, 16)));
dataset.set('medium', blobs.getBuffer('mid.jpg'));
dataset.set('big', blobs.buffer(Math.pow(2, 26)));
// dataset.set('huge', blobs.buffer(10 * Math.pow(2, 26)));

for (let [name, buf] of dataset) {
suite(`Comparator benchmark with ${name} ArrayBuffer (${buf.byteLength} bytes)`, () => {
benchmark(`Worker`, async () => {
const vs = buf.slice(0);

return await blobCompare.compareBuffers(buf, vs);
}, {maxTime: 1});

benchmark(`Main thread`, async () => {
const vs = buf.slice(0);

return await blobCompare.compareBuffers(buf, vs, false);
}, {maxTime: 1});
}, {
onComplete() {
dataset.delete(name);
}
});
}
51 changes: 0 additions & 51 deletions benchmarks/blob-comparator.bench.js

This file was deleted.

52 changes: 0 additions & 52 deletions benchmarks/blob-converter.bench.js

This file was deleted.

Loading

0 comments on commit bd97b69

Please sign in to comment.