<div>
  <button id='concat'>concat</button>
  <button id='spread'>スプレッド構文</button>
  <ul id='logContainer'></ul>
</div>
button {
    border: 0;
    cursor: pointer;
    margin: 0;
    display: inline-flex;
    outline: 0;
    padding: 0;
    position: relative;
    align-items: center;
    user-select: none;
    border-radius: 0;
    vertical-align: middle;
    -moz-appearance: none;
    justify-content: center;
    text-decoration: none;
    background-color: transparent;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
}

input {
  display: inline-flex;
  outline: none;
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid #0002;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}

button {
  color: #fff;
  background-color: #3f51b5;
  box-shadow: 0px 3px 1px -2px rgb(0 0 0 / 20%), 0px 2px 2px 0px rgb(0 0 0 / 14%), 0px 1px 5px 0px rgb(0 0 0 / 12%);
      padding: 6px 16px;
    font-size: 0.875rem;
    min-width: 64px;
    box-sizing: border-box;
    transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,border 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
    font-weight: 400;
    line-height: 1.75;
    border-radius: 4px;
    letter-spacing: 0.02857em;
    text-transform: uppercase;
}

button:hover {
  background-color: #303f9f;
}

button:active {
  box-shadow: 0px 5px 5px -3px rgb(0 0 0 / 20%), 0px 8px 10px 1px rgb(0 0 0 / 14%), 0px 3px 14px 2px rgb(0 0 0 / 12%);
}
// @ts-check

const CONTAINER = 'logContainer';

/** 配列の要素数の基準値 */
const BASIS_COUNT = 100000;

/** 配列を`concat`で結合する関数 */
const concatFunc = (a, b) => a.concat(b);
/** 配列をスプレッド構文で結合する関数 */
const spreadFunc = (a, b) => [...a, ...b];

const assessment = (func) => {
  const container = document.getElementById(CONTAINER);
  if (!container) {
    throw new Error('Not found container');
  }
  container.innerHTML = '';

  const arrs = new Array(2).fill(new Array(BASIS_COUNT).fill(0));

  for (let i = 0; i < 10; i++) {
    const start = new Date();
    for (let j = 0; j < 100; j++) {
      func(arrs[0], arrs[1]);
    }
    const end = new Date();

    const li = document.createElement('li');
    li.textContent = `${end.getTime() - start.getTime()}ms`;
    container.append(li);
  }
};

const assessmentConcat = () => assessment(concatFunc);
const assessmentSpread = () => assessment(spreadFunc);

document.getElementById('concat').addEventListener('click', assessmentConcat);
document.getElementById('spread').addEventListener('click', assessmentSpread);

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.