my

Benchmark created on


Preparation HTML


Setup



const PluginCopyWebpackByConfig = (copy) => {
    const copyParams = [];

    Object.keys(copy).forEach((copyConfig) => {
        if (!Array.isArray(copy[copyConfig])) {
            copy[copyConfig] = [copy[copyConfig]];
        }

        copy[copyConfig].forEach(value => copyParams.push(value));
    });
};

const PluginCopyWebpackByConfigNew = (copy) => {
    const copyParams = Object.entries(copy)
        .flatMap(([, value]) => (Array.isArray(value) ? value : [value]));
};

const PluginCopyWebpackByConfigValues = (copy) => {
    const copyParams = [];

    Object.values(copy).forEach((copyConfig) => {
        if (!Array.isArray(copyConfig)) {
            copyConfig = [copyConfig];
        }

        copyConfig.forEach(value => copyParams.push(value));
    });
};

const data = {
  debugbar: [
    {
      from: '*.js',
      to: './js',
      context: 'node_modules/php-debugbar/src/DebugBar/Resources'
    },
    {
      from: 'widget.js',
      to: './js',
      context: 'node_modules/php-debugbar/src/DebugBar/Resources/widgets/templates'
    }
  ],
  images: {
    from: '**/*',
    to: '../mobile/images/',
    context: './src/mobile/images/',
    globOptions: { ignore: [Array] }
  },
  favicons: { from: '**/*', to: './favicons', context: './src/common/favicons/' },
  manifest: {
    from: './manifest.json',
    to: './manifest.json',
    context: './src/mobile/'
  },
  browserconfig: {
    from: './browserconfig.xml',
    to: './browserconfig.xml',
    context: './src/mobile/'
  }
};

Test runner

Ready to run.

Testing in
TestOps/sec
original
PluginCopyWebpackByConfig(data)
ready
newOptimize
PluginCopyWebpackByConfigNew(data)
ready
newValues
PluginCopyWebpackByConfigValues(data)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.