Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Benchmark Laravel Package

dragon-code/benchmark

Simple PHP benchmarking tool to compare execution speed (and memory) between multiple code paths. Use the bench() helper or Benchmark class, pass callbacks as named args or arrays, and print clean min/max/avg/total results to the console.

View on GitHub
Deep Wiki
Context7

Simple comparison of code execution speed between different options

Frequently asked questions about Benchmark
How do I install dragon-code/benchmark in a Laravel project?
Run `composer require dragon-code/benchmark --dev` to install it as a development dependency. The package is lightweight and requires no additional Laravel configuration or service provider setup.
Can I use this package to benchmark Eloquent queries or Laravel caching strategies?
Yes, it’s perfect for comparing Eloquent query builders, raw SQL, or caching methods like Redis vs. database. Pass closures capturing Laravel dependencies (e.g., `Model::where()` or `Cache::get()`) to the `bench()` helper or `Benchmark` class.
Does dragon-code/benchmark work with Laravel’s Artisan commands?
No, it doesn’t provide built-in Artisan commands, but you can integrate it into custom Artisan commands or CLI scripts. For example, add benchmarks to `app/Console/Kernel.php` or create a custom command using `php artisan make:command`.
How does the outlier trimming feature work, and should I enable it?
When running more than 9 iterations, the package automatically trims the top and bottom 10% of results to reduce noise from external factors like garbage collection. Enable it by default for cleaner averages, especially in shared hosting or CI environments.
Is dragon-code/benchmark compatible with Laravel 10+ and PHP 8.1+?
Yes, the package supports PHP 8.1+ and works seamlessly with Laravel 9/10+. It’s MIT-licensed, actively maintained, and has no dependencies beyond PHP core, ensuring compatibility with Laravel’s ecosystem.
Can I integrate benchmark results into Laravel Telescope or monitoring tools?
Yes, use the `toData()` method to export results as an array and log them to Laravel Log, Sentry, or a database table. For real-time monitoring, pair it with Telescope’s custom panels or third-party tools like Grafana.
How do I benchmark async Laravel jobs (e.g., Horizon) with this package?
This package runs benchmarks sequentially, so it won’t reflect async/queue workloads. For queue jobs, use Laravel’s built-in queue workers or tools like Blackfire, which support async profiling. For local testing, simulate async with `Bus::dispatch()` and measure time manually.
What’s the best way to use dragon-code/benchmark in PHPUnit or Pest tests?
Add benchmarks to your test suite using assertions like `toAssert()->toBeAvgTime(from: 0, till: 100)`. For example, create a `BenchmarkTestCase` trait or use Pest’s `@benchmark` annotations. Run benchmarks in CI with `php artisan test --group=benchmark`.
Will this package work in CI/CD pipelines (e.g., GitHub Actions) for performance gates?
Absolutely. Add a GitHub Actions workflow to run benchmarks and fail builds if regressions exceed thresholds. Use `toAssert()` to enforce performance SLOs, like `toBeRegressionTime(max: 15)`. Store snapshots in version control for historical comparisons.
Are there alternatives to dragon-code/benchmark for Laravel performance testing?
For deeper profiling, consider Blackfire or Xdebug. For simpler comparisons, this package is ideal. If you need dashboards, pair it with Laravel Telescope or export data to Grafana. For async workloads, use Laravel’s queue workers or tools like Spatie’s Laravel Horizon.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony