Posts tagged with performance

How migrations might be slowing down your Laravel tests

alexvanderbist.com

Having a lot of migrations might slow down your tests. My colleague Alex shares how you can fix this.

One of the larger test suites I run daily has about 1500 tests in it. It takes just over 4 minutes to complete at an average of 160ms per test. That's pretty good. However, lately I've noticed a delay between starting PHPUnit and running the first test. This delay grew to the point where running a single test would take almost 12 seconds with the setUp method using most of that time on... migrations.

Read more [alexvanderbist.com]

Tips to Speed up Your Phpunit Tests

laravel-news.com

On the Laravel News blog, Tim MacDonald wrote a nice collection of tips on how to make PHPUnit tests run faster.

Having a fast test suite can be just as important as having a fast application. As a developer, getting feedback quickly about the state of your code allows for a much quicker development turnaround. Here we are going to run through some tips you can implement today to make your tests run faster.

Read more [laravel-news.com]

Join thousands of developers

Every two weeks, I share practical tips, tutorials, and behind-the-scenes insights from maintaining 300+ open source packages.

No spam. Unsubscribe anytime. You can also follow me on X.

Dynamic relationships in Laravel using subqueries

reinink.ca

Jonathan Reininck wrote a cool article on how you can create dynamic releationships. This technique will keep the number of queries and the memory used to a minimum.

I hope that gives you a good overview of how you can use subqueries to create dynamic relationships in Laravel. This is a powerful technique that allows you to push more work into the database layer of your app. This can have a huge impact on performance by allowing you to drastically reduce the number of database queries executed and overall memory used.

Read more [reinink.ca]

Loading Eloquent relationship counts

timacdonald.me

There are three ways of loading relationships in Laravel. Tim MacDonald, a freelance dev based in Sydney, explains them all.

It is often useful to show the number of related models a given instance has, but not actually need any specific information about the related models, just how many exist. In this scenario you do not want to load all of the related models into memory to count them, we want our database to do the heavy lifting for us. Laravel offers a number of ways to retrieve relationship counts.

Read more [timacdonald.me]

Major performance problems when running PhpStorm on a scaled resolution

stitcher.io

It's very frustrating I can't use a scaled resolution on my Mac because of PhpStorm.

PhpStorm has had performance issues on OSX for a very long time now, sometimes to the point of being unusable. I've written about these issues before, but it's good to keep a regularly updated list of what's going on. So without further ado: if you're on OSX (Sierra, High Sierra or Mojave); if you're experiencing PhpStorm performance issues, this post might help you.

Read more [stitcher.io]

Inside look at modern web browser

developers.google.com

Mariko Kosaka, an engineer at Google, started a beautifully illustrated series on how Chrome works behind the scenes.

In this 4-part blog series, we’ll look inside the Chrome browser from high-level architecture to the specifics of the rendering pipeline. If you ever wondered how the browser turns your code into a functional website, or you are unsure why a specific technique is suggested for performance improvements, this series is for you.

Read more [developers.google.com]

A new website for Spatie: backend highlights

by Freek Van der Herten – 7 minute read

For the first time in 4 years we completely redesigned our company website. We launched it today. The site is a simple Laravel app with some technical niceties. True to form we also open sourced the app, you can find the code in this repo on GitHub. In this blogpost I'd like you to give you a tour…

Read more

Benchmarks on sorting and serializing associative arrays vs classes in PHP

steemit.com

Larry Garfield, director of developer experience at Platform.sh, published some interesting numbers on arrays vs classes.

The first thing we can conclude is that if the one and only thing you care about is serialization/deserialization performance, associative arrays still win. They're the most time efficient by more than 50%, and the most space efficient by up to 20%. The second thing we can conclude is that stdClass should be used basically never. It's slower and more memory intensive than arrays in every circumstance. Just don't go there.

Read more [steemit.com]

Introducing React Suspense

At the Zeit conference React core member Andrew Clark showed off an upcoming React feature named Suspense. It can automatically pause the render process of a component if it hasn't got all its data. In can be used to avoid things like spinner showing up too quickly.

Async rendering in React gives us a powerful new set of primitives for addressing longstanding problems in UI development. I'll discuss React's vision for how async rendering can improve data fetching, code delivery, prefetching, view transitions, and more.

Read more

Improving the performance of spatie/laravel-permission

Barry van Veen recently fixed an interesting performance issue at our permissions package.

Recently I was investigating the performance of an application we have built at SWIS. To my surprise, one of the most excellent costly methods was part of the spatie/laravel-permission package. After reading some more it was clearly a performance issue that could be improved upon. Since the solution was already clearly outlined it was quite easy to code it and submit a pull request.

https://barryvanveen.nl/blog/46-improving-the-performance-of-spatie-laravel-permission

Read more

How CircleCI Improved Our Build Time

In a new post on his Medium Blog, Laravel.io maintainer Dries Vints wrote how he managed do drastically improved the build time of the popular forum.

CircleCI 2.0’s builds run with Docker which makes spinning up new instances super fast. If you use pre-built images which are customized to your needs, you don’t even need to do any provisioning during the build which saves you quite a bit time. Pulling various images and orchestrating them in a CircleCI 2.0 config allows for very rapid build times. If you add their new workflows to their mix you could easily enable parallelization and speed things up even more.

https://medium.com/laravelio/how-circleci-improved-our-build-time-8d5c40b8cc60

Read more

Separate Interactive Test Suites

If you find yourself having a bunch of slow tests that don't need to execute every time you run the tests, take a look at PHPUnit's defaultTestSuite setting. TJ Miller explains it in a blog post he wrote last year.

To avoid running the interactive test suite with the rest of my tests, manually or via a CI job, I had to explicitly include all the other suites using phpunit --testsuite Api,Feature,Unit. This felt a bit grim and I would rather exclude just that one suite. So I did some digging and found the defaultTestSuite configuration for phpunit.

https://medium.com/@sixlive/separate-interactive-test-suites-f6fd59316ec2

Read more

laravel-medialibrary v7 has been released ?

by Freek Van der Herten – 14 minute read

laravel-medialibrary is a powerful package that can help handle media in a Laravel application. It can organise your files across multiple filesystems, generate thumbnails, optimize images and much much more. At Spatie we use this package in nearly every project. The last few months our team has…

Read more

Responsive images done right

Our team is currently prepping a new version of our medialibrary. One of the highlights is support for responsive images. On his blog my colleague Brent explains what it entails and why it is important.

I want to share some thoughts on responsive images. I'll write about a certain mindset which many projects could benefit from: small- and mid-sized web projects that don't need a full blown CDN setup, but would enjoy the performance gain of responsive images.

https://www.stitcher.io/blog/responsive-images-done-right

Read more

Beyond React 16

Today at the JSConf in Iceland, React core developer Dan Abramov demonstrated some very cool features that will soon land in React.

We’ve built a generic way to ensure that high-priority updates don’t get blocked by a low-priority update. We call this time slicing. If my device is fast enough, it feels almost like it’s synchronous; if my device is slow, the app still feels responsive. We’ve also built a generic way for components to suspend rendering while they load async data. We call this feature suspense. You can pause any state update until the data is ready, and you can add async loading to any component deep in the tree without plumbing all the props and state through your app and hoisting the logic.

https://reactjs.org/blog/2018/03/01/sneak-peek-beyond-react-16.html

Read more

PHP-DI 6: turning into a compiled container for maximum performance

In a new post on his blog Matthieu Napoli, creator of PHP-DI, explains how he made v6 much faster.

But the good thing is that, after 6 years of existence, the project has matured and is now quite stable. The original objectives are met, even though there is of course always room for improvements and innovation. There is room to push the container to be better on other levels. And the most obvious one is performances.

PHP-DI 6 will be much, much faster because it is a compiled container.

http://php-di.org/news/21-php-di-6-compiled-container.html

Read more