From 4c0cb2204e0924131aad564b99ef56d64659f1cd Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Fri, 3 Aug 2012 11:56:26 +0000 Subject: Serialisation corrigée : json c'est une connerie... mais php embarque des fonctions de serialisation qui vont bien. 3m30 au parsing 30 secondes à la lecture de l'ensemble (118Mo sur disque, 800Mo en RAM) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note : faut pas parser tous les tests case !! Note2 : les gros blocs de commentaire de début de fichiers pourraient être sautés git-svn-id: file:///var/svn/2012-php-weave/trunk@12 d972a294-176a-4cf9-8ea1-fcd5b0c30f5c --- .../src/php-weave/abstract_weaver.class.php | 6 +++--- .../src/php-weave/json_serialiser.class.php | 12 ------------ poc/poc02-compiling-cake/src/php-weave/main2.php | 5 ++++- .../src/php-weave/php_serializer.class.php | 12 ++++++++++++ 4 files changed, 19 insertions(+), 16 deletions(-) delete mode 100644 poc/poc02-compiling-cake/src/php-weave/json_serialiser.class.php create mode 100644 poc/poc02-compiling-cake/src/php-weave/php_serializer.class.php diff --git a/poc/poc02-compiling-cake/src/php-weave/abstract_weaver.class.php b/poc/poc02-compiling-cake/src/php-weave/abstract_weaver.class.php index f9eb513..1bc7bce 100644 --- a/poc/poc02-compiling-cake/src/php-weave/abstract_weaver.class.php +++ b/poc/poc02-compiling-cake/src/php-weave/abstract_weaver.class.php @@ -1,6 +1,6 @@ parser = new PHPParser_Parser(new PHPParser_Lexer); $this->nodeDumper = new PHPParser_NodeDumper; $this->prettyPrinter = new PHPParser_PrettyPrinter_Zend; - $this->serializer = new PHPParser_JSONSerialiser; + $this->serializer = new PHPParser_PHPSerializer; $this->unserializer = &$this->serializer; $this->ast_dump_before_walk=""; $this->ast_dump_after_walk=""; @@ -218,7 +218,7 @@ abstract class AbstractWeaver { } public function unserializeAST($src_filepath) { - return $this->serializer->unserialize($src_filepath); + return $this->serializer->unserialize(file_get_contents($src_filepath)); } public function findAllFiles($basepath, $regexMatch, $regexPrune, $already_found=array(), $level=0) { diff --git a/poc/poc02-compiling-cake/src/php-weave/json_serialiser.class.php b/poc/poc02-compiling-cake/src/php-weave/json_serialiser.class.php deleted file mode 100644 index 40f55ce..0000000 --- a/poc/poc02-compiling-cake/src/php-weave/json_serialiser.class.php +++ /dev/null @@ -1,12 +0,0 @@ -findAllFiles("../workdir/cache", '/\.ast$/', '/^$/'); $asts=array(); + +echo memory_get_usage()."\n"; + foreach ($filelist as $f) { echo "Unserializing '$f'\n"; $asts[]=$weaver->unserializeAST($f); } -echo memory_get_usage(); +echo memory_get_usage()."\n"; ?> diff --git a/poc/poc02-compiling-cake/src/php-weave/php_serializer.class.php b/poc/poc02-compiling-cake/src/php-weave/php_serializer.class.php new file mode 100644 index 0000000..c987d0e --- /dev/null +++ b/poc/poc02-compiling-cake/src/php-weave/php_serializer.class.php @@ -0,0 +1,12 @@ +