تماشای این درس نیاز به اشتراک حرفه‌ای دارد.

Reintroducing Benchmarks0:00

Okay, so I added back that 25,000 iteration loop so that we can go back to like benchmarking this thing and just see how fast our little toy is. So this is that list of metrics from before, if you recall, where we had like a full button that was 200 milliseconds for 25,000 of them, the bear button that was just basically an empty component is 80 milliseconds, and then down until two milliseconds. So let's see where it's not going to be inline speeds, but I think it's going to be pretty

Testing Non-Optimized Compile0:33

So let's see where it's not going to be inline speeds, but I think it's going to be pretty darn close. We have it blaze optimized. Let's do the non optimized version first, okay, non optimized, I'm going to hit save. Ready? Okay, it compiles it. You see all of normal blade, it took 87 milliseconds. Okay, that about lines up.

Measuring Blaze Optimization0:48

You see all of normal blade, it took 87 milliseconds. Okay, that about lines up. Now let's add our blaze here and check it out six milliseconds. We went from all that cruft to just a simple require statement. And this is legit, like you may be thinking like, okay, cool, but this isn't real. It is real. Like what we built doesn't support props or slots, like, you know, you can't do anything like this, but it does work for the use case that we have it right now.

anything like this, but it does work for the use case that we have it right now. It actually works. It uses a reg X to match and compile and put in storage and swap out. And real blaze works basically the same way. We just have to do more work to support all those other things that I just described. But it works basically the same way. So what you're seeing is we actually use, you know, prepare string for compilation using

So what you're seeing is we actually use, you know, prepare string for compilation using or whatever. Like we do that stuff. I use file get contents and string contains and things like that. They actually exist in the source code. We're building a real version of blaze and we're massively speeding things up, right? So this is that first level of optimization. You remember from blaze, PHP dot dev, we say there's three levels of

Explaining Three Performance Levels1:58

So this is that first level of optimization. You remember from blaze, PHP dot dev, we say there's three levels of performance. There's an optimized compiler. There's memoization and folding. We saw the optimize compiler, we're bypassing blades thing and we're just directly requiring a compiled view. That is the optimized compiler that you saw. But then there's memoize and fold.

Demonstrating Real-World Overhead2:15

That is the optimized compiler that you saw. But then there's memoize and fold. And why do we need those? We're so close to taking no time at all. Well, of course, we just bypassed all of blades overhead. If there's anything complicated inside here, like, let's do this. Let's do you sleep. I sleep, we all sleep 100. Okay. Let's see how long that benchmark takes.

Okay. Let's see how long that benchmark takes. It probably takes too long. I probably shouldn't have put that in there, but it's 100 microseconds like that's not even that's half a millisecond, right? So times 25, I don't know, it's going to be a while because this also has to run like five of them and then divide them by five. So maybe that was a little bit of a mistake.

five of them and then divide them by five. So maybe that was a little bit of a mistake. Okay. 3.5 seconds. Let's make it 10. Okay. And we'll run that. That should be 10 times faster. Hopefully three. Okay.

Hopefully three. Okay. 400 milliseconds. That's a little more realistic. So you have something in there and you can see that you sleep 10 microseconds like it's not even a millisecond. You could easily have things in here attribute, bag merging, giant list of props, giant match and switch statements, maybe you're requiring files, maybe you're looking

props, giant match and switch statements, maybe you're requiring files, maybe you're looking something with auth, you're checking auth user, maybe you're hitting the session, you're hitting a cache, you're hitting the database, whatever, you're doing stuff that makes your components more expensive than nothing. So yeah, we've removed all of blades overhead, but what about all the other overhead?

Introducing Memoization Next3:33

So yeah, we've removed all of blades overhead, but what about all the other overhead? What about the necessary overhead? How can we cut that out? And that's where we get into memoize and folding. Let's tackle the first one, memoization. We'll do that in the next episode. We'll see you there.

دوست دارید گاهی خبرهای Laracasts را ایمیل کنیم؟