https://github.com/awilum/craft-benchmark
Simple benchmark plugin with basic benchmark functionality for Craft CMS.
https://github.com/awilum/craft-benchmark
Last synced: over 1 year ago
JSON representation
Simple benchmark plugin with basic benchmark functionality for Craft CMS.
- Host: GitHub
- URL: https://github.com/awilum/craft-benchmark
- Owner: Awilum
- License: mit
- Created: 2022-11-24T01:12:43.000Z (over 3 years ago)
- Default Branch: 1.x
- Last Pushed: 2022-12-12T11:28:12.000Z (over 3 years ago)
- Last Synced: 2024-10-11T03:06:26.405Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 38.1 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
Benchmark plugin for Craft CMS
Simple benchmark plugin with basic functionality for benchmarking.
## Requirements
* **Craft CMS**: ^4.0
* **PHP**: ^8.0
## Installation
To install the plugin, follow these instructions.
1. Open your terminal and go to your Craft project:
```
cd /path/to/project
```
2. In your terminal run `composer require awilum/craft-benchmark`.
3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Benchmark.
### Usage
```
{% do benchmarkStart('fetch_news') %}
{% set entryQuery = craft.entries()
.section('news')
.orderBy('postDate DESC')
.limit(10) %}
{% do benchmarkEnd('fetch_news') %}
Time elapsed: {{ benchmarkSummary()['fetch_news']['time']['elapsed_formated'] }}
Memory usage: {{ benchmarkSummary()['fetch_news']['memory']['usage_formated'] }}
//=> Time elapsed: 1ms
//=> Memory usage: 3.46KB
```
#### Functions
PHP function
Twig function
Description
Awilum\CraftBenchmark\benchmarkStart
benchmarkStart
Start benchmark prob.
Awilum\CraftBenchmark\benchmarkEnd
benchmarkEnd
End benchmark prob.
Awilum\CraftBenchmark\benchmarkDelete
benchmarkDelete
Delete benchmark prob.
Awilum\CraftBenchmark\benchmarkFlush
benchmarkFlush
Flush benchmark prob.
Awilum\CraftBenchmark\benchmarkSummary
benchmarkSummary
Get benchmark summary.
## Tests
Run tests
```
./vendor/bin/pest
```
## LICENSE
[The MIT License (MIT)](https://github.com/awilum/craft-benchmark/blob/master/LICENSE.md)
Copyright (c) [Sergey Romanenko](https://awilum.github.io/)