« first day (2201 days earlier)      last day (2748 days later) » 

6:01 PM
What is the unit for the duration of a video in JS? Seconds?
 
that's not a real question. What kind of video? Where from?
 
const vid = document.createElement('video');
vid.src = 'http://somevideourl.com/video.mp4';
vid.addEventListener('durationchange', () => {
  const duration = vid.duration;   // <- what is the unit of this?
})
 
if you knew what the duration was, couldn't you just log that and compare?
 
testing is too hard
 
have you tried looking it up?
 
6:06 PM
ask siri
 
just seems inconsistent... most things are milliseconds, no?
 
it varies
 
Everything should be measured in planck units
 
I make 1 million plank-dollars / year :(
 
parsecs
 
6:12 PM
> the Grand unification epoch, where gravitation is separated from the unified force of the Standard Model
the unification epoch, when things split up and were no longer unified
this is why nobody takes you science types seriously
 
@ssube What's the best way to advance and get more monsters if you can't get any further on a level? Just keep beating the previous?
 
bro, do you even grind?
 
^
@BenFortune strengthen your existing ones, awaken and rune them, eventually collect enough to evolve them.
spend 100 red crystals on an XP booster and spend a hungover saturday grinding
 
rubs existential dread-stained palms together Oh boy. So I got a dilemma here.
This little experiment
 
@AlexMitan lol
 
6:16 PM
@rlemon Runescape :D
 
It has background in the comments, but basically I came up with a simple distance function that was around 98% accurate but seemingly way smarter and quicker
 
@AlexMitan and more complicated
 
Basically instead of having radii around a point be circles, let them be octagons, because that seems easier to compute, and it should be
Boy.... it's not.
It's actually slower: jsfiddle.net/bpw3d5ry
 
octagons do not fall in the category of shapes you can draw inside out
which means they're computationally bad
 
Can anyone help me understand not just why it's slower, but why in the world the IF determines the speed the most? Have a look at the fiddle
 
6:17 PM
How dare you. My father was an octogon.
 
the shape just ends up being an octagon, it's not drawn in any way
 
@Luggage I FART IN YOUR GENERAL DIRECTION
 
that's the distance "heatmap"
 
15968
Q: Why is it faster to process a sorted array than an unsorted array?

GManNickGHere is a piece of C++ code that seems very peculiar. For some strange reason, sorting the data miraculously makes the code almost six times faster. #include <algorithm> #include <ctime> #include <iostream> int main() { // Generate data const unsigned arraySize = 32768; int data[arr...

is a small part of your answer
 
@AlexMitan Dude tag that as nsfw, people don't wanna see @Luggage's parents doing the horizontal tango
 
6:18 PM
otherwise, your octo math is just far, far more complex
 
Committing geometric adultery
 
the only slow part of a traditional distance is the sqrt, which is manageable
 
<gasp> those shapes are overlapping
 
I love this room
 
there's usually no division, and division is bad
 
6:19 PM
okay, but even with the multiplication....hm, wait dives into a pile of tools
 
been noted
I'm late to the party
 
Apparently it's not!
 
it is a slow operation
 
one of the slowest single opcodes
 
if you can just square both sides, do that instead
 
6:20 PM
although if and function calls can do more damage
 
Oh my god, I removed the division and now it's just dx + dy and it's still slower, what is happening
 
the sheer number of Math.abs calls is probably killing your octo algorithm
 
which is slower for you?
 
for me octoMath was faster every time i ran it
 
Octo distance with if:
VM121:98 octoIf: 62.972ms
VM121:100 Octo distance with max and min:
VM121:109 octoMath: 40.743ms
VM121:111 Pythagorean theorem:
VM121:120 pyth: 37.508ms
 
Is it the face?
 
remember, Pythagorean is SUB; SUB; MUL; MUL; ADD; SQRT;, so you have to get under the sum cost of those ops
and SUB, MUL, and ADD are all almost free
although I'm not sure a 200ms benchmark is enough to actually get good numbers
 
I can't imaging this is happening, but a conditional would prevent any sort of SIMD optimization, won't it?
 
SIMD?
 
I think the penalty to branch prediction would be more serious.
 
6:25 PM
!!mdn simd
 
@SterlingArcher Something went on fire; status 403
 
dammit
 
@ssube Oh, believe me I let this crap go for a lot more on my local
 
single instruction, multiple data.
 
although a good JIT will use SIMD for the pyth version
 
6:26 PM
which makes it superior
also correct
 
if you really want to get into the details, this site has tables of instruction latency and such
 
Wait, so a lot of code on one line is better?
 
I don't.
 
but tbh, the octo one is just way more complex
@AlexMitan lines don't matter, it's the number and type of operations
 
isolating everything seems to also make a difference
 
6:27 PM
Right, and I don't want to be dense, but wasn't sqrt all expensive and everything else in octo not so much?
 
obviously one ADD is faster than two, simple math is faster than sqrt, and literally anything in the known universe is faster than a function call
 
Hi. I have a tiny fiddle that changes a control's border when the text in the control is changed, but it requires a click off the control to trigger. Is there a way to make it trigger as soon as typing begins?
https://jsfiddle.net/L6y5y14d/11/
 
because you re-use a lot the compiler is probably de-optimizing things.
 
lemon's tweak cuts octoIf from ~93 to 62, here
pyth goes from 43 to ~40
 
@rlemon Wait wait wait what did you do there?
 
6:29 PM
wrapped the for's in iife's because it was easier (for me) than renaming the variables inside.
and used a new array per test.
however the data would be even better if the arrays were each unique in values.
 
iife?
 
you should really be running the whole test scenario twice, once to warm it up and once to actually sample
 
immediately invoked function expression.
 
But the takeaway from all this branching out is that pyth really is rather better or kind of just as good?
 
it's equally fast to min/max and more accurate
and most of the time, you can leave off the sqrt
 
6:32 PM
pfff....... yeah... but.... ugh, it goes against everything I thought I knew and I'm still not sure why
 
compilers evolve
.innerHTML is no longer slow
pisses me off so much :D
 
@AlexMitan min and max will, unless you're on a really bad runtime, be getting inlined. Both are very small functions.
 
I love physical simulations and algorithmic graphics and such, and everyone tells me to minimise sqrt and find "better" ways to compute things, and the "DX + DY" thing just makes negative sense to me
 
the best way to minimize sqrt is to compare the squares
 
6:34 PM
^
square both sides if you can
 
again, because MUL is super cheap
but my guess for octoMath being competitive is the functions being inlined and turned into bitwise ops
 
Math.sqrt = (input) => input / 10; //close enough
 
processors.wiki.ti.com/index.php/… can u plz pre-compile for me thnxs
I somehow am incapable of following instructions today
 
@Luggage ..wait, erm.. what
 
I wasn't being serious.
 
6:37 PM
yea, who () single args.
 
me
 
Math.sqrt = input => input / 10; // much better
 
@Luggage Ah, lol. Sorry I just don't know what's real any more, is all
 
@rlemon noo
 
yissss
 
6:38 PM
Sorry if me Q was too simplistic, I found a solution.
https://jsfiddle.net/L6y5y14d/12/
 
i prefer with ^^
easier to scan
 
@AlexMitan micro optimizations aren't real
 
you'll go crazy with them
compilers evolve dude, these things can change tomorrow
 
if you were writing C/++, thinking about them would make sense, but the costs in JS are somewhat different (usually around objects)
 
generally I follow the rule: only worry about performance once it becomes an issue.
 
6:39 PM
and either way, you can tell node to dump the assembly
 
The cost in JS is your sanity.
 
@ssube I did play around with points as {} plain objects vs class objects.... class was over 7 times faster... should I post the tests here just for the hell of it?
 
Why is javascript indented so ...uh... badly? Serious question.
 
it isn't
 
@SeventhSon That's all you, buddy.
 
6:40 PM
Not trying to start a war.
 
indentation is your own style choice.
whitespace isn't significant
 
@AlexMitan that is rather strange, I wouldn't expect such a wide difference
 
@ssube what's that?
 
I wouldn't mind seeing them
 
Yes, I understand it's a style choice but it seems all C# dev's indent in a way that seems logical to me and javascript, typically, no so much.
 
6:41 PM
10
Q: Dump v8 JIT output from node

slipheedCan node.js (or some other v8 interface or wrapper around v8) output the generated assembly from the v8 JIT? I'd like to see what the generated assembly looks like for various snippets.

 
@SeventhSon click "tidy" at the top of jsfiddle
ohh, you don't like { on the same line?
 
@SeventhSon those are two different style points, which became popular among many languages in their own respects.
I can't remember the names now
 
correct and incorrect
 
lol
 
@AlexMitan also, read up on how v8 optimizes things
 
6:42 PM
hey, we are losing mushrooms, here!
ah
 
it's too soon for that meme to come back
 
@bitten it may or may not be BadgerCat's birthday
 
IT JUST GETS WEIRDER AND WEIRDER!
 
!!riot
 
Okay, so the test results are reversed in jsfiddle
 
6:44 PM
╯°□°)╯┻━┻
 
@ssube ahh
 
Don't laugh but I want to style my JS indeting like this.
https://jsfiddle.net/L6y5y14d/13/
 
classes are way slower on jsfid, but much quicker locally
 
then it's the perfect time
 
I run it with atom's node runner
 
6:44 PM
@SeventhSon wat
 
so basically node
 
@SeventhSon the { on a new line, I can understand. The ( on a new line.. eww.
 
@SeventhSon lolwat. nobody writes code like that.
 
I'm aware that no one write JS like that.
 
@AlexMitan jsfiddle.net/q1vac9ko/1 and now?
 
6:45 PM
lol
But it makes me comfortable.
 
@AlexMitan those are in no way equivalent
 
I write my LINQ code the same way
 
@SeventhSon good, just make sure you pass it to a tidy module before you show anyone else
 
@SeventhSon I've never seen any language written like that. C# certainly isn't.
 
it's basically how many newlines can i use until i break the compiler
 
6:46 PM
@ssube lisp?
 
I want my brackets to be clearly open and closed on their own lines.
 
58 secs ago, by rlemon
@SeventhSon good, just make sure you pass it to a tidy module before you show anyone else
 
@rlemon What did you change?
 
i used to see a lot of that in cfml, ( on one line, args one per line after, then a closing )
 
@SeventhSon well, programming doesn't do that, math doesn't do that, written language doesn't do that...
 
6:46 PM
hated it
 
so I think you're alone in that awful style
 
@AlexMitan did it make a difference?
 
I guess I'll get used to it.
I mean your way! lol
(everyone else's way)
 
6:48 PM
// If you have many arguments, then (sometimes):
foo(
    arg1,
    arg2,
    arg3,
    arg4
);
 
you could always code it your own way, and package it as a module
then noone else has to look at it
 
If you don't write your code minified from the first minute of coding you are basically not coding, so I heard.
 
from @towc ??
 
I disagree. When in JS-land I follow normal JS conventions. When in c#-land I follow c# conventions.
 
@rlemon ??
 
6:49 PM
@AlexMitan nah, you're just wasting your time and everybody else's. Code should be easy to read, the compiler makes it easy to run.
 
Well I just stopped by to ask that simple question about keyup change. Laters.
 
I'm just messing around but that single open ( on its own line made me have to compensate
But back to my tests, why do my local tests show a huge gap in favour of classes, while jsfid does the opposite?
And what did you change?
 
the engine you are running on?
 
@AlexMitan your two methods are totally, entirely different
 
@AlexMitan did it make a difference?
I want to know
 
@rlemon I posted the screenshot after your thing, it seems to have made a diff
 
@SterlingArcher that's super old. iirc. there is a video of it on youtube
someone capped it and reposted it and didn't even show the end
@AlexMitan yes, I don't know what your initial tests were
and I unwrapped the fiddle. your load options were "onload"
so everything was running inside window.onload = function () { ... }
be careful about sandbox defaults.
they are (usually) bad places to test perf
 
node is definitely a better test platform if you want relative differences
 
^
more dependable at least
 
it does less weird stuff like, yknow, rendering a window
 
6:53 PM
Right? Okay, so should I trust my "one js file and nothing else in node" tests most?
 
you should use a comprehensive statistical model and repeated tests to find the norms and deviation, then compensate for bias in each population
or you can test on node
 
or don't be concerned when 50 million ops happens in 50ms vs 40ms
 
Basically... and yeah, @ssube, if I open up my R I end up overdosing on statistics so I still have to stay half-sane
 
I'm trying a schitzophrenia simulator to see if it effects me
Just saw it on imgur
 
6:56 PM
especially when your benchmark mostly tests math, since the math ops tend to have a reciprocal throughput < 1
@SterlingArcher things look pretty much the same, right?
 
Hey, guys. I'm hoping I'm in the right place to bring this up. I tried posting this as a question, and I've gotten one pretty good response, but oddly I've received two close votes; I don't really get why. I'm guessing this is the right place to talk about concepts of minification via gulp. Would that be accurate? If so, do you guys mind if I drop the link to my question, or is that a faux pas?
 
"reciprocal throughput < 1"?
I'm sorry for being nooby
 
Oh man this is weird
 

« first day (2201 days earlier)      last day (2748 days later) »