JavaScript performance is weird... Write scientifically faster code with benchmarking

  Рет қаралды 87,413

Beyond Fireship

Beyond Fireship

Күн бұрын

Пікірлер: 218
@pokefreak2112
@pokefreak2112 14 сағат бұрын
The benchmarks should really also include memory allocations. array map/filter create new a new copy of the array every time so even if they look decent on isolated benchmarks they put load on the GC which may introduce lag spikes if you spam them too much.
@lbgstzockt8493
@lbgstzockt8493 10 сағат бұрын
And memory reads. I would rather do ten compares than one RAM read.
@CTSSTC
@CTSSTC Сағат бұрын
We should just transpile code and let it choose the best for loop :P maybe allow an annotation for expected loop size or even better let the runtime figure it out and optimize over time due to it running its own measurements ;D These are things we shouldn't be worried about when it could potentially be automated. We should instead be focused on conveying expectations.
@allesarfint
@allesarfint 7 сағат бұрын
0:24 "Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%."
@AbdelhakOussaid
@AbdelhakOussaid 15 сағат бұрын
Shout out to those developers, like me, who write gibberish and it works!
@ARandomUserOfThisWorld
@ARandomUserOfThisWorld 15 сағат бұрын
I don’t just use a DB… I use an excel spreadsheet, and when it runs of space(which is hardcoded at like 1mil rows), it creates a new spreadsheet with a new ID which is specified in the filename and nowhere else, and use that, all of those files together, instead of a DB. And all of them are .xlsx files btw.
@vikingthedude
@vikingthedude 14 сағат бұрын
@@ARandomUserOfThisWorld awesome. I use fopen
@sad_man_no_talent
@sad_man_no_talent 14 сағат бұрын
@@ARandomUserOfThisWorld I just use a json file
@everythingisfine9988
@everythingisfine9988 13 сағат бұрын
💪👑
@Alfakatt
@Alfakatt 13 сағат бұрын
Us
@cosmiclattemusic
@cosmiclattemusic 15 сағат бұрын
can't unsee NODE transitioning to DONE 😭
@k00lmoh
@k00lmoh 13 сағат бұрын
you mean DENO
@orcagaming2143
@orcagaming2143 12 сағат бұрын
No he means done but it'll be oden before it because done😊
@jackiedo7370
@jackiedo7370 7 сағат бұрын
NODE -> DENO -> ODEN -> DONE 🎉
@erikjohnson9112
@erikjohnson9112 14 сағат бұрын
Quicksort is not a stable sort. With a stable sort routine equal items will have the same relative order compared to the original. Quicksort does not have this feature. Most of the time you might not care, but that IS a difference worth noting.
@dentjoener
@dentjoener 14 сағат бұрын
Thank you, and with sort getting faster on strings, it's probably trying to minimize comparisons, something TimSort does in Java and Python, because comparing is more expensive. Plus TimSort is stable.
@eliasepg
@eliasepg 10 сағат бұрын
7:52 "you're good enough even when you're not at your best" love this statement, very deep
@ErazerPT
@ErazerPT 11 сағат бұрын
As pertains to the first example, repeat after me children : I shall NOT microbenchmark things where the function call overhead overshadows the work being done by an order of magnitude or more. Seriously, this is such a common thing it should be a meme for all intents and purposes. Now, show us a run where the work being done doesn't amount to "basically nothing at all", ie, something a tiny bit realistic...
@noirsociety
@noirsociety 15 сағат бұрын
"Languages that try to disallow idiocy become themselves idiotic." -- Rob Pike
@okie9025
@okie9025 13 сағат бұрын
sounds a lot like rust to me
@netssrmrz
@netssrmrz 9 сағат бұрын
great quote. sounds like React to me.
@randomuser66438
@randomuser66438 9 сағат бұрын
​@@okie9025Here they come
@shellderp
@shellderp 8 сағат бұрын
The key point here is our programmers are Googlers, they’re not researchers. They’re typically, fairly young, fresh out of school, probably learned Java, maybe learned C or C++, probably learned Python. They’re not capable of understanding a brilliant language but we want to use them to build good software. So, the language that we give them has to be easy for them to understand and easy to adopt. It must be familiar, roughly C-like. Programmers working at Google are early in their careers and are most familiar with procedural languages, particularly from the C family. The need to get programmers productive quickly in a new language means that the language cannot be too radical. Actual Rob Pike quote
@kasper_573
@kasper_573 11 сағат бұрын
The most important thing to measure is the performance of your application, not your modules or functions. Measure those once you’ve detected a performance issue with your app, and need to drill down as to why and fix the issue. A slow sum or sort is usually pointless to optimize if its impact on your app is negligible.
@V3racious3
@V3racious3 14 сағат бұрын
This Deno commerical brought to you by Deno.
@rawallon
@rawallon 14 сағат бұрын
A Deno a day keeps the exception away
@johnvomberg450
@johnvomberg450 14 сағат бұрын
The introduction was the most interesting part of this video.
@k98killer
@k98killer 5 сағат бұрын
Technically, there is a fifth way to loop: `for (let i=arr.length-1; i>=0; i--)` or `for (let i=0,l=arr.length; i
@jakeave
@jakeave 15 сағат бұрын
We've been able to squeeze out more by declaring i before and not using a lookup for the length. I know it sounds terrible, but it's ever so slightly faster. let i = 0; const len = arr.length for (; i < len; i++) Use at your own peril.
@jerichaux9219
@jerichaux9219 14 сағат бұрын
I've done similar. As long as you maintain ownership over the array (to ensure the length isn't suddenly shorter than it was when you'd began), this is fine.
@JasminUwU
@JasminUwU 13 сағат бұрын
​@@jerichaux9219 That sounds like an absolutely horrible bug to discover
@S7hadow
@S7hadow 13 сағат бұрын
I can see .length as having a slight overhead and so making a difference over a big number of loops. But the declaration of i doesn't seem logical to me as that part of the for loop is only run once. Guess I have to try Deno bench now
@rumfordc
@rumfordc 12 сағат бұрын
@@S7hadow i believe the declaration is because scoping rules for loops are different from the rest of the function in javascript. the interpreter also needs to differentiate between which type of for-loop it is, which the semi-colon disambiguates immediately as opposed to reading the entire declaration before knowing which type of loop the declaration is for.
@rumfordc
@rumfordc 12 сағат бұрын
also making that a while-loop should be faster than a for loop
@zeikjt
@zeikjt 4 сағат бұрын
8:02 Yes, yes, noooooo! Using something like Deno bench doesn't tell you where bottlenecks in your program are! You need to profile your actual code in-situ. Then if you prove there's a bottleneck somewhere and it is affecting the performance of your program in a meaningful way then you can use bench to try and find faster alternatives, but then you need to test it again in-situ to make sure it actually performs better. You might have misunderstood the shape of the data, or the shape of the traffic to your code and find that your speed up didn't actually change much. You can't always test these things accurately synthetically, and you won't know it until you try it with the real thing :)
@thepaintedsock
@thepaintedsock 2 сағат бұрын
Great video. The for loop can be sped up even more if you create the for(let i=0, len=arr.length; i < len; ++i)
@r5LgxTbQ
@r5LgxTbQ 10 сағат бұрын
5:20 no fair, your benchmark doesnt account for the compute power to create the Set in the first place. You're not starting from the same place so it's not an accurate comparison
@zeikjt
@zeikjt 4 сағат бұрын
Ideally you'd be using a Set from the get-go instead of an array, then you are starting from the same place. But if it's an all-at-once allocation instead of incremental then sure. This is why benchmarks are not ideal, test your real code to find actual bottlenecks and then you have the real situation.
@sahilaggarwal2004
@sahilaggarwal2004 15 сағат бұрын
The set example is not really accurate. Although I agree that it definitely provides performance benefits over Array.includes() in case of large data but while benchmarking we must also include the one time overhead taken to create the set as we are originally dealing with array data type.
@aleksander5298
@aleksander5298 14 сағат бұрын
that's why small array is faster than small set, but big set is faster than big array, you edgy boy
@Slackow
@Slackow 14 сағат бұрын
@@aleksander5298 big set is only faster if you actually keep the set up to date, and use it for multiple times, if you remake the set every single time then it's slower.
@beyondfireship
@beyondfireship 14 сағат бұрын
I disagree. The array is already in memory, so the Set should be too. The objective is to "find an element", not create the original data structure. One-time setup is insignificant on a task that runs millions of times. But just for fun, recreated the Set on each benchmark run and it still performed 20x faster.
@aleksander5298
@aleksander5298 13 сағат бұрын
@@Slackow why would you remake set lmao are you dumb? just use set instead of array, ez, you have skill issue or what?
@sahilaggarwal2004
@sahilaggarwal2004 13 сағат бұрын
@beyondfireship yeah that's what I said, set will be faster, no doubt in that. But the performance gain is not a million times faster if we consider the time to create the set too, and that's what I felt was inaccurate.
@patric_forreal
@patric_forreal 3 сағат бұрын
Using the SET trick to sort is much like using hash map ✅
@lwinklly
@lwinklly 14 сағат бұрын
Anton mentioned 🎉
@MelroyvandenBerg
@MelroyvandenBerg 8 сағат бұрын
Yes he was. I'm recently creating quite some PRs for his tests 😅
@Dominik-K
@Dominik-K 15 сағат бұрын
Rob Pike mention ftw
@RandomGeometryDashStuff
@RandomGeometryDashStuff 13 сағат бұрын
06:49 unfair test! `[69,420].toSorted()` result is `[420,69]` but other sort functions output is `[69,420]`
@mmanomad
@mmanomad 13 сағат бұрын
Love seeing more Deno videos!
@pirixyt
@pirixyt 12 сағат бұрын
You forgot to loop with a while loop.
@brandongregori995
@brandongregori995 9 сағат бұрын
Probably the exact same as a for I loop
@M0du5Pwn3n5
@M0du5Pwn3n5 7 сағат бұрын
It is worth saying: Knuth was talking about fiddling with bits in assembly. He was NOT talking about writing your programs in a basically performant way. He was CERTAINLY not saying "don't think about performance at all until later". Rob Pike's rules assume that you are writing your program in a sane way already, rather than in dog-slow nightmare spaghetti. There is a reason that Go is designed the way it is - it's not because all organizations of your program are equally valid and the structure doesn't matter until the end when you measure it. If you write your code in an inherently slow way, then once you measure it, it is too late. When you go to measure it, you will discover that there is no particularly expensive part you can optimize because the entire thing is sludge. Also, quicksort is not a fancy algorithm. It is known and extremely easy to copy. If you are not confident about your ability to google quicksort and write it correctly, you should find another career.
@netssrmrz
@netssrmrz 9 сағат бұрын
great video. would love to see a version for frontend.
@tomasprochazka6198
@tomasprochazka6198 10 сағат бұрын
The initialization of Set takes some time though, should be included in the benchmark too
@zeikjt
@zeikjt 4 сағат бұрын
Only if the Set is temporary, if you use a Set instead of an Array altogether then it's the same thing.
@piff57paff
@piff57paff 4 сағат бұрын
Even then, there is more overhead during insertion. So you still need to look at it holistically.
@zeikjt
@zeikjt 4 сағат бұрын
@@piff57paff i suppose it does depend on whether the data is always created in bulk or incremental. This is why you don't find bottlenecks via these kind of benchmarks, you time your real code so you know the situation
15 сағат бұрын
Deno is becoming awesome
@vaisakh_km
@vaisakh_km 13 сағат бұрын
All thanks to bun.. Our cute little deno couldn't haddle the competition from Js's round buns XD
@RustIsWinning
@RustIsWinning 12 сағат бұрын
​@@vaisakh_kmHahaha nice copium from the runtime with 500+ segfaults 😂
@thatsalot3577
@thatsalot3577 12 сағат бұрын
​@@RustIsWinningyeah but you can't deny the fact that they're the reason why deno is atleast trying to do better because pre deno 2 there wasn't much reason to use it. And I find bun to be still pretty good for servers and web sockets
@RustIsWinning
@RustIsWinning 9 сағат бұрын
@@thatsalot3577 Wrong. Yall just living under a rock and getting benchmarkbrainwashed by twitter influencer andys who are still stuck with the worse ecosystem lmao
@vaisakh_km
@vaisakh_km 3 сағат бұрын
@@RustIsWinning there is no wrong or right... compatition is always improves the products.. period. I don't and never says bun is better than deno... deno will be always better at compatibility due to v8 engine
@jackgame8841
@jackgame8841 6 сағат бұрын
i could become performance engineer after this course
@deatho0ne587
@deatho0ne587 12 сағат бұрын
forOf is my goto now a days for looping. One it is one of the faster and it is also easiest to think about in pseudocode.
@QuentinBzt
@QuentinBzt 54 минут бұрын
Bro is sold to the DENO cause, we wanna see Bun content as well 😛
@danser_theplayer01
@danser_theplayer01 6 сағат бұрын
I have one easy tip for performance. All array methods suck arse, and are hard to read, just write a for loop. This is the best answer every time all time. There is no question. If you do more than one thing then you'll chain methods without realising that you're looping more than once. Even if you don't chain, you still need to run a callback on methods. The for in/of loops are generators. Therefore the fastest is ALWAYS a regular for loop. I only write for loops because I don't know for sure that the array or object will be small enough, and also for loops are extremely versatile (doing what you usually do with 3 loop methods, in one loop), and readable.
@oleg4966
@oleg4966 28 минут бұрын
Eh, I'm quite fond of filter and sort methods. They're a PITA to translate to a pure for loop, and the resulting code is hard to read.
@DomskiPlays
@DomskiPlays 14 сағат бұрын
Started a new job a few months ago and have fallen in love with maps and sets in combination with the data array. Fuck the users RAM, they want SPEED :D
@brandongregori995
@brandongregori995 9 сағат бұрын
You should look into sparse sets. They are pretty cool. It's like a faster map
@WiseWeeabo
@WiseWeeabo 7 сағат бұрын
let a = new Array(42); if (Object.seal) { a.fill(undefined); Object.seal(a); } Use fixed length arrays if you want to be fast.
@codernerd7076
@codernerd7076 15 сағат бұрын
Deno course!!!
@gro967
@gro967 6 сағат бұрын
"scientifically faster" is the important part of the video title.
@CottidaeSEA
@CottidaeSEA 10 сағат бұрын
Premature optimization is no good, but don't write code with poor performance if you know it'll process a lot of data. It's not premature at that point.
@amine7
@amine7 2 сағат бұрын
How else would you later make your service 5x faster and create a blog post and a youtube video bragging about it?
@CottidaeSEA
@CottidaeSEA 2 сағат бұрын
@amine7 Could do what a colleague of mine did. Do a big import, loop through the file and compare for every potential matching item in the database. That way I could improve the performance by 1000x.
@nicsilver12
@nicsilver12 12 сағат бұрын
Are you ok man? You sound a little down compared to your usual. Either way awesome video!
@aleksander5298
@aleksander5298 15 сағат бұрын
In the sumUsingForLoop you should make arr.length a separate variable to make it faster
@whyneet
@whyneet 13 сағат бұрын
In databases, the index lookup performance is not O(1), but O(log n) assuming the index uses a B-Tree
@pixiedev
@pixiedev 12 сағат бұрын
Right, but he is not talking about database. it's for Set which uses hashing and is O(1) in almost every time.
@Exilum
@Exilum 10 сағат бұрын
Sets are almost always O(1), and the worst case isn't even that bad.
@dave6012
@dave6012 9 сағат бұрын
@@pixiedevhe compared the O(1) lookup of a Set to a database index, which as @whyneet pointed out, is not O(1).
@MaulikParmar210
@MaulikParmar210 12 сағат бұрын
Irony is people want performance from high level language like JS for which multiple runtime exists, each trying to impmement same stuff very differently from each other. If you really need it, than you won't be using JS or Go or even rust and rely C for close to metal performance. It also has own abstractions so it really drills down to a Software Engineers ability to understand machine at it's core level. Unfortunately alot of devs are not computer engineers or taught formally about computer architecture so squeezing out performance would be done by someone who excels in both relms and most of the world won't even need that kind of optimizations either. Thus compering benchmarks is pretty amature, at the end of the day solution and it's worthiness totally depends in usecase specific implementation. These type of comparison is inevitable because of lack of education on topics thst really matters after some point. And no if you're writing your app in JS for loading millions of records, that's not going to give you performance that a bare metal code will provide. Choose your tools wisely.
@funkmedaddy
@funkmedaddy 6 сағат бұрын
In a perfect world you get to choose your tools, but we do not live in a perfect world and sometimes you're just given the tools and have to work with them. While it's worth pointing out that JS should not be your language of choice for performance oriented tasks, it doesn't mean you can't try and make the best of what you have
@vighnesh153
@vighnesh153 56 минут бұрын
In the bubble sort implementation, I noticed that you were swapping variables using the array destructuring syntax: [a, b] = [b, a]. For small arrays, this is fine, but if the arrays are large, then creating a new array allocation just for swapping might also cause GC which will slow down the entire bubble sort impl. For benchmarking, it would be better to swap the variables the tradition way by creating a temp variable.
@FirroLP
@FirroLP 11 сағат бұрын
If you can still change the video in your course: Not including the creation in the benchmark is a big flaw because creating a set is slower than an array. Obviously doesn't make such a difference, but it's a mistake and worth talking about
@zeikjt
@zeikjt 4 сағат бұрын
I think y'all are thinking that you'd still have an Array, but why? Just use the Set the whole time, no need for the original Array.
@jimbobu
@jimbobu 7 сағат бұрын
JavaScript developers when iterating over an array is slower than a single equality comparison: 🤯
@82TheKnocKY
@82TheKnocKY 8 сағат бұрын
These examples don't consider the fact that JavaScript is a JITed language. These microbenchmarks are never accurate to how little/much this function would actually get optimized if it was in a real application
@sugaith
@sugaith 8 сағат бұрын
these Rob Pike rules are perfect
@JimmyCerra
@JimmyCerra 12 сағат бұрын
The Centauri write in Javascript. The Narn write in Python. The Shadows use C++. The Vorlons use Java.
@npc-drew
@npc-drew Сағат бұрын
...and God write in Rust. 😎
@theprantadutta
@theprantadutta 5 сағат бұрын
Performance, you say, I have never heard of it.
@edumorango
@edumorango 14 сағат бұрын
One hash map to rule them all
@zeikjt
@zeikjt 4 сағат бұрын
Lua got it figured out!
@Roboprogs
@Roboprogs 9 сағат бұрын
Thanks? I’ve been programming for 40 years, and these days I generally don’t worry about performance in the browser or Node, other than code and data size. The sort and search stuff pretty much all happens in the database. So I have to make all the execution time measurements against THAT, and avoid crippling it with stupid crap like ORM. So, yeah, same process, but not the place I run it. Batch C code on files in the 90s. Again, same process.
@krowhenkvothe6010
@krowhenkvothe6010 14 сағат бұрын
Like for the DENO course
@npc-drew
@npc-drew Сағат бұрын
like because this account is a bot.
@ciCCapROSTi
@ciCCapROSTi Сағат бұрын
Yeah, to be fair if you are speed conscious, you shouldn't use js. That doesn't mean you should ignore speed best practices of course. But doing big data in JS is just asking for trouble. That's what Python is for, with its C bindings.
@RustIsWinning
@RustIsWinning 12 сағат бұрын
Deno is so winning!! B word could never 😂
@kacaii3349
@kacaii3349 14 сағат бұрын
More videos about Deno please!!
@madbanana22
@madbanana22 8 сағат бұрын
Best js benchmarking strategy: 1. Are you using js outside the web frontend? 2. Don't
@ktech4246
@ktech4246 3 сағат бұрын
All this time i have be using traditional for loops because I was too lazy to learn a cleaner way. Looks like my laziness has paid off!
@muscifede
@muscifede 14 сағат бұрын
code simple, test thoroughly, fix it
@danser_theplayer01
@danser_theplayer01 6 сағат бұрын
But if you're really looking to optimise a sorting algorithm, and have solid static typing, and don't want to learn a completely different language... Use a systems language like assemblyscript.
@jordymaryns4945
@jordymaryns4945 15 сағат бұрын
I hope there will be a lifetime purchase option in the future as well.
@DoubleDYouTube
@DoubleDYouTube 12 сағат бұрын
When you're creating a new set of 10 000 elements, you're using a lot more memory in comparison to using "includes". It's still a much better solution, but I feel like it should be mentioned at least.
@user-ii7xc1ry3x
@user-ii7xc1ry3x 15 сағат бұрын
YAY new course!
@RealRogerFK
@RealRogerFK 10 сағат бұрын
Unless you're doing a game, game server or something that's REALLY mission critical these silly little benchmarks are more of a "Okay, this little replacement takes me 10 mins to implement and saves me this much ram and lets me have up to 10K users instead of 1K" In reality, you don't even have 10 users, but at least you'll sleep well knowing Bun takes less RAM... b-because i-it does, r-right?
@B1aQQ
@B1aQQ 9 сағат бұрын
It's a misleading oversimplification to say the type of loop doesn't matter if the array is small. It might not matter if it runs infrequently. But if it's a part of a high traffic path, then you can have hundreds of small loop executions a second and that would mean the small differences can compound into an impactful performance hit.
@trappedcat3615
@trappedcat3615 14 сағат бұрын
It matters if the array is large... or if the number runs on that small array is large
@Kiyuja
@Kiyuja 8 сағат бұрын
trad loop gave me life
@pippinproductions
@pippinproductions 14 сағат бұрын
java script users when they discover what a set is
@stereocodes
@stereocodes 14 сағат бұрын
what's java script? Java users when they learn its actually Javascript and has nothing to do with Java.
@unknownguywholovespizza
@unknownguywholovespizza 12 сағат бұрын
​@@stereocodesit's so annoying when people say Java instead of JavaScript
@fghdfghdfgghdstwesdfjtykjyfgk
@fghdfghdfgghdstwesdfjtykjyfgk 11 сағат бұрын
@@stereocodes but oracle owns javascript 🤔
@robinmitchell6803
@robinmitchell6803 2 сағат бұрын
5:16 -> Did you include the time to organise that array? If not, you can't compare the two.
@BritishBagelGaming
@BritishBagelGaming 9 сағат бұрын
5:35 , thought it would be fair to include the initialisation of Set from the array within the benchmark, no?
@itsmenewbie03
@itsmenewbie03 9 сағат бұрын
Rust mentioned let's Goooooo 🦀🦀
@MelroyvandenBerg
@MelroyvandenBerg 8 сағат бұрын
Gooo also mentioned
@MelroyvandenBerg
@MelroyvandenBerg 8 сағат бұрын
Gooo also mentioned 😅
@RustIsWinning
@RustIsWinning 4 сағат бұрын
Winning! Zig could never lmao 🦀🦀
@floppa9415
@floppa9415 13 сағат бұрын
"Premature optimization is the root of all evil" is one of the dumbest quotes, especially if you think about things on a larger scale. If your architecture is stupid and leads to brutal overhead, for example by needlessly splitting up things into microservices that communicate over rest, you can't "optimize" yourself out of that easily. At that point you have to basically start over.
@morchellemusic2829
@morchellemusic2829 10 сағат бұрын
I think you got the quote wrong dude 😂
@musicstar8885
@musicstar8885 5 сағат бұрын
Best video till date
@MelroyvandenBerg
@MelroyvandenBerg 8 сағат бұрын
Instant tinnitus due to your sound effects 😢
@JJJMMM1
@JJJMMM1 4 сағат бұрын
5:40 the analogy between database indexes and O(1) Set lookups doesn't make sense to me. Most database indexes are stored as B-trees or B+trees, and the lookup complexity there is O(log n). So either the time complexity of a Set lookup is also O(log n), or the Set is actually stored as a hashmap - which is what I would've guessed - giving you an average case of ~ O(1).
@IngwiePhoenix
@IngwiePhoenix 13 сағат бұрын
So, how many "nodejs-bench" packages do exist by now?
@sugarsama7716
@sugarsama7716 14 сағат бұрын
It's kinda misleading... I run a bench with the same quicksort implementation, and it was about 97% slower than Array.prototype.sort,
@ucmRich
@ucmRich 14 сағат бұрын
*** How can we put JavaScript (or the whole deno) in a cpp program for use as a scripting language for programming game logic in a 3D game engine? DXStudio used JavaScript as it's scripting language and I want to put that into another game engine or just make my own game engine with JS. Can Deno be used for this?
@darkenlightmage
@darkenlightmage 12 сағат бұрын
If you include and link the node or deno (or just the V8) runtime with the project, you can directly invoke the interpreter inside whatever application you want. It is then a matter of passing the right values to the interpreter environment so that you can modify external values using JS.
@AndreSpecht
@AndreSpecht 15 сағат бұрын
Amazing video. Could you share the code? Would love to use it with my students
@Filaxsan
@Filaxsan 7 сағат бұрын
GOLD video!
@alekseykarpenko2681
@alekseykarpenko2681 2 сағат бұрын
Would these results be different in Node?
@cathalogrady2331
@cathalogrady2331 10 сағат бұрын
I feel like you have to apply pikes principles a bit different considering JS doesn't even have an optimizer.
@AvanaVana
@AvanaVana 2 сағат бұрын
Why didn’t you include the array to set conversion in the benchmark for set?
@marcmcintosh6715
@marcmcintosh6715 8 сағат бұрын
can you add to the suite? ``` function sum(arr: number[], count = 0) { if (arr.length === 0) return count; const [head, ...tail] = arr; return sum(tail, count + head) } ```
@mateja176
@mateja176 13 сағат бұрын
I wish JavaScript had zero cost abstractions.
@floppa9415
@floppa9415 12 сағат бұрын
At this point you don't have JS
@thatsalot3577
@thatsalot3577 12 сағат бұрын
Dude it was supposed to be a frontend language, which runs in browser and was used to make buttons go click click, at this point you just like the js syntax.
@monawoka97
@monawoka97 12 сағат бұрын
Traditional for loop is fastest. C chads knew it all along.
@narrei666
@narrei666 14 сағат бұрын
does set also work this well for array of objects?
@ence7846
@ence7846 10 сағат бұрын
no
@turun_ambartanen
@turun_ambartanen 10 сағат бұрын
at 5:40-5:50 you say that a JS set is like a DB index. Is it really? I would have expected the set to work on hashes, but the index to work on a balanced binary tree.
@ence7846
@ence7846 10 сағат бұрын
This is an implementation detail but Set are just binary tree in js, like Map
@jontancool9181
@jontancool9181 13 сағат бұрын
This was uploaded at a perfect time as i was planning to work with benchmarking of a framework for my exam work
@Waterfly-v7q
@Waterfly-v7q 10 сағат бұрын
Nice guide how to look at JS (meaning the most popular runtime V8) perf like a amateur xd
@brogotbonkers
@brogotbonkers 13 сағат бұрын
that's an ad? I've tried to create a blog with Deno but it really sucked. not even close to what Ryan promised on demos lol
@RandomGeometryDashStuff
@RandomGeometryDashStuff 13 сағат бұрын
06:22 does `[result[j], result[j+1]] = [result[j+1], result[j]];` create and iterate array?
@codyrap95
@codyrap95 11 сағат бұрын
It creates a temporary array in memory and then destructures it as it's easier than creating a third variable to store the temporary value of result[j]
@LuanDavi
@LuanDavi 9 сағат бұрын
amazing content!
@anb4351
@anb4351 6 сағат бұрын
Damn foreach loop is bad. I have pretty large foreach loops throughout my codebase
@tomasprochazka6198
@tomasprochazka6198 10 сағат бұрын
Why it isn't optimized by a compiler ... oooh
@fermin7c1
@fermin7c1 9 сағат бұрын
You keep calling functions passed to a method "callbacks" when they are just functions, nothing is calling back to them, they are just executed
@1apostoli
@1apostoli 6 сағат бұрын
strings sort by radix
@robchr
@robchr 13 сағат бұрын
What is the zeroith rule?
@anotherone2398
@anotherone2398 12 сағат бұрын
use C.
@samuelebernardi1162
@samuelebernardi1162 12 сағат бұрын
Wouldn't the time to copy the array items to a set be longer than the actual research?
@mrdmajor
@mrdmajor 10 сағат бұрын
It's hilarious watching web developers rant about performance but then also be hypebeasts for bloated frameworks, to build "apps". 🤣
@jeevandza3464
@jeevandza3464 2 сағат бұрын
can you tell about WinterJS
@WiseWeeabo
@WiseWeeabo 7 сағат бұрын
K-nooth
How on Earth does ^.?$|^(..+?)\1+$ produce primes?
18:37
Stand-up Maths
Рет қаралды 78 М.
ЗНАЛИ? ТОЛЬКО ОАЭ 🤫
00:13
Сам себе сушист
Рет қаралды 3,7 МЛН
😜 #aminkavitaminka #aminokka #аминкавитаминка
00:14
Аминка Витаминка
Рет қаралды 2,3 МЛН
We Fell For The Oldest Lie On The Internet
13:08
Kurzgesagt – In a Nutshell
Рет қаралды 2,3 МЛН
I tried 8 different Postgres ORMs
9:46
Beyond Fireship
Рет қаралды 432 М.
I Feel Bad For New Programmers
19:12
ThePrimeTime
Рет қаралды 491 М.
Apple, Stop Putting Things On the Bottom Please
9:16
TechLinked
Рет қаралды 190 М.
this new Linux feature makes hacking IMPOSSIBLE
11:08
Low Level
Рет қаралды 151 М.
How is this Website so fast!?
13:39
Wes Bos
Рет қаралды 739 М.
When you Accidentally Compromise every CPU on Earth
15:59
Daniel Boctor
Рет қаралды 870 М.
Dear Functional Bros
16:50
CodeAesthetic
Рет қаралды 542 М.
Every programming language explained in 15 minutes | Prime Reacts
43:42
The sneaky reason Ferrari suddenly has an F1 title shot
10:16
THE RACE
Рет қаралды 340 М.