@@ -17,6 +17,8 @@ class NodeListCommand extends BasePhpcrCommand
17
17
protected $ formatter ;
18
18
protected $ textHelper ;
19
19
protected $ maxLevel ;
20
+ protected $ time ;
21
+ protected $ nbNodes ;
20
22
21
23
protected function configure ()
22
24
{
@@ -54,6 +56,10 @@ public function execute(InputInterface $input, OutputInterface $output)
54
56
$ this ->showChildren = $ input ->getOption ('children ' );
55
57
$ this ->showProperties = $ input ->getOption ('properties ' );
56
58
$ this ->showTemplate = $ input ->getOption ('template ' );
59
+ $ this ->time = 0 ;
60
+ $ this ->nbNodes = 0 ;
61
+
62
+ $ config = $ this ->get ('config.config.phpcrsh ' );
57
63
58
64
$ session = $ this ->get ('phpcr.session ' );
59
65
$ path = $ input ->getArgument ('path ' );
@@ -70,7 +76,10 @@ public function execute(InputInterface $input, OutputInterface $output)
70
76
$ filter = substr ($ filter , 1 );
71
77
}
72
78
79
+
80
+ $ start = microtime (true );
73
81
$ nodes = $ session ->findNodes ($ parentPath );
82
+ $ this ->time = microtime (true ) - $ start ;
74
83
}
75
84
76
85
if (!$ this ->showChildren && !$ this ->showProperties ) {
@@ -88,10 +97,18 @@ public function execute(InputInterface $input, OutputInterface $output)
88
97
}
89
98
}
90
99
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
+ }
91
107
}
92
108
93
109
private function renderNode ($ currentNode , $ table , $ spacers = array (), $ filter = null )
94
110
{
111
+ $ this ->nbNodes ++;
95
112
if ($ this ->showChildren ) {
96
113
$ this ->renderChildren ($ currentNode , $ table , $ spacers , $ filter );
97
114
}
@@ -103,7 +120,9 @@ private function renderNode($currentNode, $table, $spacers = array(), $filter =
103
120
104
121
private function renderChildren ($ currentNode , $ table , $ spacers , $ filter = null )
105
122
{
123
+ $ start = microtime (true );
106
124
$ children = $ currentNode ->getNodes ($ filter ? : null );
125
+ $ this ->time += microtime (true ) - $ start ;
107
126
108
127
$ nodeType = $ currentNode ->getPrimaryNodeType ();
109
128
$ childNodeDefinitions = $ nodeType ->getDeclaredChildNodeDefinitions ();
0 commit comments