@@ -17,6 +17,8 @@ class NodeListCommand extends BasePhpcrCommand
1717 protected $ formatter ;
1818 protected $ textHelper ;
1919 protected $ maxLevel ;
20+ protected $ time ;
21+ protected $ nbNodes ;
2022
2123 protected function configure ()
2224 {
@@ -54,6 +56,10 @@ public function execute(InputInterface $input, OutputInterface $output)
5456 $ this ->showChildren = $ input ->getOption ('children ' );
5557 $ this ->showProperties = $ input ->getOption ('properties ' );
5658 $ this ->showTemplate = $ input ->getOption ('template ' );
59+ $ this ->time = 0 ;
60+ $ this ->nbNodes = 0 ;
61+
62+ $ config = $ this ->get ('config.config.phpcrsh ' );
5763
5864 $ session = $ this ->get ('phpcr.session ' );
5965 $ path = $ input ->getArgument ('path ' );
@@ -70,7 +76,10 @@ public function execute(InputInterface $input, OutputInterface $output)
7076 $ filter = substr ($ filter , 1 );
7177 }
7278
79+
80+ $ start = microtime (true );
7381 $ nodes = $ session ->findNodes ($ parentPath );
82+ $ this ->time = microtime (true ) - $ start ;
7483 }
7584
7685 if (!$ this ->showChildren && !$ this ->showProperties ) {
@@ -88,10 +97,18 @@ public function execute(InputInterface $input, OutputInterface $output)
8897 }
8998 }
9099
100+ if ($ config ['show_execution_time_list ' ]) {
101+ $ output ->writeln (sprintf (
102+ '%s nodes in set (%s sec) ' ,
103+ $ this ->nbNodes ,
104+ number_format ($ this ->time , $ config ['execution_time_expansion ' ]))
105+ );
106+ }
91107 }
92108
93109 private function renderNode ($ currentNode , $ table , $ spacers = array (), $ filter = null )
94110 {
111+ $ this ->nbNodes ++;
95112 if ($ this ->showChildren ) {
96113 $ this ->renderChildren ($ currentNode , $ table , $ spacers , $ filter );
97114 }
@@ -103,7 +120,9 @@ private function renderNode($currentNode, $table, $spacers = array(), $filter =
103120
104121 private function renderChildren ($ currentNode , $ table , $ spacers , $ filter = null )
105122 {
123+ $ start = microtime (true );
106124 $ children = $ currentNode ->getNodes ($ filter ? : null );
125+ $ this ->time += microtime (true ) - $ start ;
107126
108127 $ nodeType = $ currentNode ->getPrimaryNodeType ();
109128 $ childNodeDefinitions = $ nodeType ->getDeclaredChildNodeDefinitions ();
0 commit comments