Download the PHP package green-elephpant/code-bench without Composer

On this page you can find all versions of the php package green-elephpant/code-bench. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package code-bench

Green ElePHPant - CodeBench

The Green ElePHPant wants to help you to reduce the carbon emissions of your software.

One way of doing so is to optimize the performance. Less CPU, RAM and Storage means reduced energy consumption, fewer carbon emissions, and less hardware to be produced. And, last but not least, the users of your software will benefit from a faster application.

GreenElephpant\CodeBench is a simple benchmark tool that can help you to improve the performance of your code by benchmarking several possible solutions and helps you to decide which code to chose.

Key concept

GreenElephpant\CodeBench simply measures the execution time and memory consumption of callables, which contain the code you want to measure.

Shout-out to PhpBench, which is a much better solution if you need super accurate measurement, because it runs the code to be measured in isolation. It also is meant to be used as test suite similar to PHPUnit and can thus be used to catch performance regressions during CI/CD, which makes it extremely useful . However, GreenElephpant\CodeBench is your coding compadre if a quick and rough measurement is enough to decide between several options.

Installation

Simply use composer to add GreenElephpant\CodeBench to your project:

composer require green-elephpant/code-bench --dev

Note: we use require-dev here, since GreenElephpant\CodeBench should not be used in production code.

Note: for Laravel, you can use the package CodeBench Laravel.

Note: GreenElephpant\CodeBench works with PHP 7.4+ to support most code bases. However, only since PHP 8.2 the functionmemory_reset_peak_usage is available. With earlier verions, you will not be able to monitor the peak memory usage with this tool.

Configuration

GreenElephpant\CodeBench is designed to require no other dependencies to keep its footprint small, so there is nothing much to do.

Set Logger callable

By default, GreenElephpant\CodeBench uses print for logging. However, you can set a callable which takes the output and you can log it where you want.

For example, in Laravel you could do

to use whatever logger you have defined.

Note: the CodeBench Laravel package does that for you.

Usage

Basic Usage

In its purest form, the usage is as easy as the following function call:

The result should be something similar to this:

What does the output mean?

Iterations

Results can vary between several executions of the callable. To balance out any outliers, we can run several iterations and take the average. This behaviour is controlled by the $iterations parameter. The following example will run the each callable 100 times:

Pre-run callable

By default, GreenElephpant\CodeBench executes the callable one time before starting with the actual measurement. This is to avoid side effects by e.g. cache warmups. To disable this behaviour, run the benchmark with $preRunCallable set to false:


All versions of code-bench with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package green-elephpant/code-bench contains the following files

Loading the files please wait ....