<?php require_once "bootstrap.php"; $testData = unserialize(file_get_contents(__DIR__ . '/../lib/Weasel/JsonMarshaller/Config/bootstrap.cnf')); $factory = new \Weasel\WeaselDoctrineAnnotationDrivenFactory(); $weasel = $factory->getJsonMapperInstance(); $testString = $weasel->writeString($testData, '\\Weasel\\JsonMarshaller\\Config\\ClassMarshaller[string]'); $st = microtime(true); for ($i = 0; $i < 100; $i++) { $weasel->writeString($testData, '\\Weasel\\JsonMarshaller\\Config\\ClassMarshaller[string]'); } print "Writes took: " . (microtime(true) - $st) . "ms\n"; $st = microtime(true); for ($i = 0; $i < 100; $i++) { $weasel->readString($testString, '\\Weasel\\JsonMarshaller\\Config\\ClassMarshaller[string]'); } print "Reads took: " . (microtime(true) - $st) . "ms\n";
<?php /** * @author Jonathan Oddy <*****@*****.**> * @copyright Copyright (c) 2012, Moo Print Ltd. * @license ISC * * Builds the serialized bootstrap configs from the annotation driven configs. */ require_once __DIR__ . '/../vendor/autoload.php'; $factory = new \Weasel\WeaselDoctrineAnnotationDrivenFactory(); $readerProvider = $factory->getAnnotationReaderFactoryInstance(); $jsonProvider = new \Weasel\JsonMarshaller\Config\AnnotationDriver($readerProvider); $jsonProvider->setAnnotationNamespace('\\Weasel\\JsonMarshaller\\Config\\DoctrineAnnotations'); $config = array(); addConfig('\\Weasel\\JsonMarshaller\\Config\\ClassMarshaller', $config, $jsonProvider); buildSubConfig(__DIR__ . '/../lib/Weasel/JsonMarshaller/Config/Deserialization', '\\Weasel\\JsonMarshaller\\Config\\Deserialization', $config, $jsonProvider); buildSubConfig(__DIR__ . '/../lib/Weasel/JsonMarshaller/Config/Serialization', '\\Weasel\\JsonMarshaller\\Config\\Serialization', $config, $jsonProvider); addConfig('\\Weasel\\XmlMarshaller\\Config\\ClassMarshaller', $config, $jsonProvider); buildSubConfig(__DIR__ . '/../lib/Weasel/XmlMarshaller/Config/Deserialization', '\\Weasel\\XmlMarshaller\\Config\\Deserialization', $config, $jsonProvider); buildSubConfig(__DIR__ . '/../lib/Weasel/XmlMarshaller/Config/Serialization', '\\Weasel\\XmlMarshaller\\Config\\Serialization', $config, $jsonProvider); file_put_contents(__DIR__ . '/../lib/Weasel/JsonMarshaller/Config/bootstrap.cnf', serialize($config)); exit(0); function addConfig($class, &$config, \Weasel\JsonMarshaller\Config\AnnotationDriver $provider) { $config[ltrim($class, '\\')] = $provider->getConfig($class); } function buildSubConfig($dir, $bns, &$config, $provider) { $flags = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS; foreach (new FilesystemIterator($dir, $flags) as $fileInfo) {