The CLI( Command Line Interface) is one of the best places to execute a long long-running task and Laravel has provided us with the Artisan Console that allows us to create our custom commands. I usually set up custom artisan commands whenever I am building something that requires initial setup or when I want to run queries on a large DB. In this tutorial, I am going to show you how to set up a custom Artisan command and how to calculate the execution time of that command. There are two ways to create a custom Artisan Console command, the Class-Based Command and the Closure Based Command.
To calculate the execution time of a custom command we can leverage the Laravel now()helper method.