Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #29878
| From | Stefan Weiss <krewecherl@gmail.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Bubblesort |
| Date | 2016-03-10 21:14 +0100 |
| Organization | albasani.net |
| Message-ID | <nbskjb$ehr$1@news.albasani.net> (permalink) |
| References | (4 earlier) <7b1ee9db-4732-48e1-be7e-37ba62db4c6e@googlegroups.com> <nbc50g$44d$1@news.albasani.net> <2815605.oGPRxZOVvt@PointedEars.de> <nbnur4$4tr$1@news.albasani.net> <1614595.1D9Jq9LFrv@PointedEars.de> |
On 03/09/2016 22:04, Thomas 'PointedEars' Lahn wrote:
> BTW, who would be interested in a sort method that would be able to only
> sort parts of an array?
Maybe... what's the use case for this?
>> OT: You didn't mention performance, but I was curious and did a quick
>> test anyway: in current versions of Firefox and Chrome, there are no
>> huge differences, although referencing a previously created function is
>> consistently faster than using an inline expression,
>
> I expected that.
>
>> and traditional functions are consistently faster than arrow functions.
>
> I did not expect that …
>
>> In Firefox 44, inline arrow functions are noticably slower than the other
>> variants (about an order of magnitude).
>
> … that – so, are we, in the end, sacrificing performance for convenient
> syntax with arrow functions here? –,
You were right not to expect that... after rearranging my test script
and upgrading to FF45, I can't reproduce yesterday's results anymore.
The issue using sort() with inline arrow functions in Firefox still
exists, but the effect is much smaller when other array methods are
used. Sorting an empty array with FF45 (20m iterations each):
ms total ns each
function_ref: 326 16
function_inline: 650 33
arrow_ref: 329 17
arrow_inline: 4571 229
The more elements the array has, the less pronounced the difference is,
so it's possible that this only affects function creation, not execution.
Apart from this, arrow functions are pretty much on par with traditional
functions.
>> By the way, const/let are also consistently slower than var, but not by
>> much. This may be caused by the additional checks required for the
>> "temporal dead zone".
>
> … or that. Thank you for sharing this.
I only see this in Chromium (tested v48 and v49; Opera is probably also
affected); there is no difference in Firefox or Edge. Here are the
results I get in Chromium 48 for the tests below:
ms total ns each
let: 2379 238
var: 205 21
const ITERATIONS = 1e7;
const TESTS = {
"let": function (iter) {
while (iter--) {
let total = 0;
for (let i = 0; i < 10; ++i) {
let a = i;
let b = -i;
let sum = a + b;
total += sum;
}
sideEffect += total;
}
},
"var": function (iter) {
while (iter--) {
var total = 0;
for (var i = 0; i < 10; ++i) {
var a = i;
var b = -i;
var sum = a + b;
total += sum;
}
sideEffect += total;
}
},
};
var sideEffect = 0;
Full test code here: http://pastebin.com/raw/AgRUxHCJ
- stefan
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Bubblesort jonas.thornvall@gmail.com - 2016-03-04 02:00 -0800
Re: Bubblesort "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-03-04 18:53 +0800
Re: Bubblesort "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-03-04 12:01 +0100
Re: Bubblesort jonas.thornvall@gmail.com - 2016-03-04 03:03 -0800
Re: Bubblesort jonas.thornvall@gmail.com - 2016-03-04 05:15 -0800
Re: Bubblesort jonas.thornvall@gmail.com - 2016-03-04 05:41 -0800
Re: Bubblesort "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-03-04 21:56 +0800
Re: Bubblesort Stefan Weiss <krewecherl@gmail.com> - 2016-03-04 15:10 +0100
Re: Bubblesort jonas.thornvall@gmail.com - 2016-03-04 07:37 -0800
Re: Bubblesort Stefan Weiss <krewecherl@gmail.com> - 2016-03-04 17:08 +0100
Re: Bubblesort jonas.thornvall@gmail.com - 2016-03-04 07:50 -0800
Re: Bubblesort jonas.thornvall@gmail.com - 2016-03-04 07:54 -0800
Re: Bubblesort Stefan Weiss <krewecherl@gmail.com> - 2016-03-04 17:21 +0100
Re: Bubblesort Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-03-04 19:26 +0000
Re: Bubblesort "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-03-04 23:05 +0100
Re: Bubblesort jonas.thornvall@gmail.com - 2016-03-05 09:15 -0800
Re: Bubblesort Stefan Weiss <krewecherl@gmail.com> - 2016-03-08 03:43 +0100
Re: Bubblesort jonas.thornvall@gmail.com - 2016-03-08 02:41 -0800
Re: Bubblesort jonas.thornvall@gmail.com - 2016-03-08 09:10 -0800
Re: Bubblesort Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-08 23:34 +0100
Re: Bubblesort Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-08 23:46 +0100
Re: Bubblesort Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-03-09 00:16 +0000
Re: Bubblesort Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-09 02:41 +0100
Re: Bubblesort Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-08 23:35 +0100
Re: Bubblesort Stefan Weiss <krewecherl@gmail.com> - 2016-03-09 02:38 +0100
Re: Bubblesort Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-09 22:04 +0100
Re: Bubblesort Stefan Weiss <krewecherl@gmail.com> - 2016-03-10 21:14 +0100
Re: Bubblesort Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-10 22:17 +0100
Re: Bubblesort "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-03-10 22:31 +0100
Re: Bubblesort Stefan Weiss <krewecherl@gmail.com> - 2016-03-10 23:25 +0100
Re: Bubblesort "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-03-11 00:16 +0100
Re: Bubblesort "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-03-04 21:59 +0800
Re: Bubblesort "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-03-04 17:12 +0100
Re: Bubblesort Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-05 02:00 +0100
Re: Bubblesort John Harris <niam@jghnorth.org.uk.invalid> - 2016-03-05 18:39 +0000
Re: Bubblesort Scott Sauyet <scott.sauyet@gmail.com> - 2016-03-05 17:40 -0800
Re: Bubblesort "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-03-04 21:54 +0800
Re: Bubblesort "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-03-04 16:59 +0100
Re: Bubblesort jonas.thornvall@gmail.com - 2016-03-04 03:04 -0800
Re: Bubblesort jonas.thornvall@gmail.com - 2016-03-04 03:55 -0800
Re: Bubblesort Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-05 00:01 +0100
Re: Bubblesort Aleksandro <aleksandro@gmx.com> - 2016-03-06 18:41 -0300
csiph-web