My conclution: we really need improve the performance of Object,
cause that's the most frequently used Thing.
```code

performanceButton.onclick = function () {
  let startTime = Date.now()
  ChromeSamples.setStatus(`Start performance testing at time ${startTime}`);
  function testArray(count) {
    let startTime = Date.now()
    let a = []
    for (let i = 0; i < count; ++i) {
      a[i] = i + 1
    }
    return Date.now() - startTime
  }
  function testObject(count) {
    let startTime = Date.now()
    let a = {}
    for (let i = 0; i < count; ++i) {
      a[i] = i + 1
    }
    return Date.now() - startTime
  }
  function testObjectSingle(count) {
    let startTime = Date.now()
    let a = {}
    for (let i = 0; i < count; ++i) {
      a[0] = i + 1
    }
    return Date.now() - startTime
  }
  function testMap(count) {
    let startTime = Date.now()
    let a = new Map()
    for (let i = 0; i < count; ++i) {
      a.set(i, i + 1)
    }
    return Date.now() - startTime
  }
  function testUint32Array(count) {
    let startTime = Date.now()
    let a = new Uint32Array(count)
    for (let i = 0; i < count; ++i) {
      a[i] = i + 1
    }
    return Date.now() - startTime
  }
  setTimeout(function () {
    let count = 10000000
    let testResult = {
      array: testArray(count),
      object: testObject(count),
      objectSingle: testObjectSingle(count),
      map: testMap(count),
      uint32Array: testUint32Array(count),
    }
    ChromeSamples.setStatus(`Start performance ending at time
${JSON.stringify(testResult)}`);
  })
}
```
Firefox:
Start performance ending at time Start performance ending at time
{"array":340,"object":4762,"objectSingle":2699,"map":5151,"uint32Array":29}
Chrome:
Start performance ending at time
{"array":215,"object":614,"objectSingle":49,"map":6232,"uint32Array":100}

-- 
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to