On Mon, Mar 7, 2016 at 10:42 PM, 罗勇刚(Yonggang Luo) <luoyongg...@gmail.com>
wrote:

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

I agree plain objects are among "the most frequently used objects", but
here you're using them as arrays and that's not how plain objects are
typically used. Performance of setting indexed properties is mostly
unrelated to setting named properties.

That said, it's a valid performance issue so I filed bug 1254436 [0].
Thanks for reporting this. Next time you run into a JS (performance) issue,
please file a bug in the 'Core: JavaScript Engine' component :)

Thanks,
Jan

[0] https://bugzilla.mozilla.org/show_bug.cgi?id=1254436


> ```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
>
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to