@@ -52,6 +52,7 @@ class Crystal::Command
52
52
53
53
def initialize (@options : Array (String ))
54
54
@color = true
55
+ @stats = false
55
56
end
56
57
57
58
def run
@@ -172,7 +173,9 @@ class Crystal::Command
172
173
173
174
private def hierarchy
174
175
config, result = compile_no_codegen " tool hierarchy" , hierarchy: true , top_level: true
175
- Crystal .print_hierarchy result.program, config.hierarchy_exp, config.output_format
176
+ Crystal .timing(" Tool (hierarchy)" , @stats , delay: true ) do
177
+ Crystal .print_hierarchy result.program, config.hierarchy_exp, config.output_format
178
+ end
176
179
end
177
180
178
181
private def run_command (single_file = false )
@@ -190,7 +193,9 @@ class Crystal::Command
190
193
191
194
private def types
192
195
config, result = compile_no_codegen " tool types"
193
- Crystal .print_types result.node
196
+ Crystal .timing(" Tool (types)" , @stats , delay: true ) do
197
+ Crystal .print_types result.node
198
+ end
194
199
end
195
200
196
201
private def compile_no_codegen (command , wants_doc = false , hierarchy = false , cursor_command = false , top_level = false )
@@ -202,15 +207,17 @@ class Crystal::Command
202
207
end
203
208
204
209
private def execute (output_filename , run_args )
205
- begin
206
- Process .run(output_filename, args: run_args, input: true , output: true , error: true ) do |process |
207
- # Ignore the signal so we don't exit the running process
208
- # (the running process can still handle this signal)
209
- Signal ::INT .ignore # do
210
+ status = Crystal .timing(" Execute" , @stats , delay: true ) do
211
+ begin
212
+ Process .run(output_filename, args: run_args, input: true , output: true , error: true ) do |process |
213
+ # Ignore the signal so we don't exit the running process
214
+ # (the running process can still handle this signal)
215
+ Signal ::INT .ignore # do
216
+ end
217
+ $?
218
+ ensure
219
+ File .delete(output_filename) rescue nil
210
220
end
211
- status = $?
212
- ensure
213
- File .delete(output_filename) rescue nil
214
221
end
215
222
216
223
if status.normal_exit?
@@ -351,9 +358,14 @@ class Crystal::Command
351
358
opts.on(" --release" , " Compile in release mode" ) do
352
359
compiler.release = true
353
360
end
354
- opts.on(" -s" , " --stats" , " Enable statistics output" ) do
355
- compiler.stats = true
356
- end
361
+ end
362
+
363
+ opts.on(" -s" , " --stats" , " Enable statistics output" ) do
364
+ @stats = true
365
+ compiler.stats = true
366
+ end
367
+
368
+ unless no_codegen
357
369
opts.on(" --single-module" , " Generate a single LLVM module" ) do
358
370
compiler.single_module = true
359
371
end
0 commit comments