midgardproject/midgard-core — Issue #144: Improve performance of midgard_storage methods
Author: flack
Created: 2012-02-20 21:29:43+00:00
State: open

When I run this code

$re = new ReflectionExtension('midgard2');
$classes = $re->getClasses();
$counter = 0;
$start = microtime(true);
foreach ($classes as $refclass)
{
if (!$refclass->isSubclassOf('midgard_object'))
{
continue;
}
$type = $refclass->getName();
midgard_storage::class_storage_exists($type);
}
echo "found " . $counter . " schema types in " . round(microtime(true) - $start, 2) . "s";

I get the following output:

found 85 schema types in 154,82s

This is on a quad-core Xeon machine with 5GB of RAM, so I don't think it's a hardware thing. Either midgard_storage or the reflection calls must be really slow. It would be nice if this could be improved, for developing, this gets quite tiresome.