-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add benchmarks #39
Comments
Hi, @autaut03, first of all thank you for the interest in the Typhoon project. I've made a simple benchmark via TheDragonCode/benchmark using Typhoon <?php
use DragonCode\Benchmark\Benchmark;
use GoodPhp\Reflection\ReflectorBuilder;
use Symfony\Component\Filesystem\Filesystem;
use Typhoon\OPcache\TyphoonOPcache;
use Typhoon\Reflection\Cache\NullCache;
use Typhoon\Reflection\TyphoonReflector;
require_once __DIR__ . '/../../vendor/autoload.php';
$typhoonInMemory = TyphoonReflector::build();
$opcache = new TyphoonOPcache(__DIR__ . '/../../var/benchmark/cache');
$opcache->clear();
$typhoonFile = TyphoonReflector::build(cache: $opcache);
$goodInMemory = (new ReflectorBuilder())
->withMemoryCache()
->build();
(new Filesystem())->remove(__DIR__ . '/../../var/benchmark/cache');
$goodFile = (new ReflectorBuilder())
->withFileCache(__DIR__.'/../../var/benchmark/good')
->build();
Benchmark::start()
->compare([
'native reflection' => static fn(): array => (new ReflectionClass(AppendIterator::class))->getMethods(),
'typhoon, in-memory' => static fn(): array => $typhoonInMemory->reflectClass(AppendIterator::class)->getMethods(),
'good, in-memory' => static fn(): mixed => $goodInMemory->forType(AppendIterator::class)->declaredMethods(),
'typhoon, file' => static fn(): array => $typhoonFile->reflectClass(AppendIterator::class)->getMethods(),
'good, file' => static fn(): mixed => $goodFile->forType(AppendIterator::class)->declaredMethods(),
]);
Seems like Typhoon is on average faster with in-memory cache and worse with the file one. We already know, why file cache is performing worse (some architectural issues), it is already being fixed in the upcoming
I'm sorry to hear that you don't have enough time to work on your project, some healthy competition is always good. We'll be happy if you use Typhoon in your projects and give us feedback and/or contribute. |
Hey.
Some context: I'm the author of https://github.com/good-php/reflection, which is a reflection library like this one. As I don't have the resources needed to maintain it, I'm looking into replacing it with an open-source solution like yours :) My only use case for it right now is https://github.com/good-php/serialization, which is a serialization library. That requires good performance of the reflection.
So my proposal is to add benchmarks here, so we can know how performant this is and whether there's room for improvement or not :)
The text was updated successfully, but these errors were encountered: