Add compilation time to cli
This commit is contained in:
		
							parent
							
								
									dc9450f64a
								
							
						
					
					
						commit
						6f8c02ac04
					
				@ -12,6 +12,8 @@ fn main() -> Result<(), std::io::Error> {
 | 
				
			|||||||
        let object_path = parent.with_extension("o");
 | 
					        let object_path = parent.with_extension("o");
 | 
				
			||||||
        let asm_path = parent.with_extension("asm");
 | 
					        let asm_path = parent.with_extension("asm");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let before = std::time::SystemTime::now();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let text = fs::read_to_string(&path)?;
 | 
					        let text = fs::read_to_string(&path)?;
 | 
				
			||||||
        match compile(&text, PathBuf::from(&path)) {
 | 
					        match compile(&text, PathBuf::from(&path)) {
 | 
				
			||||||
            Ok(CompileOutput {
 | 
					            Ok(CompileOutput {
 | 
				
			||||||
@ -20,15 +22,20 @@ fn main() -> Result<(), std::io::Error> {
 | 
				
			|||||||
                obj_buffer,
 | 
					                obj_buffer,
 | 
				
			||||||
                llvm_ir,
 | 
					                llvm_ir,
 | 
				
			||||||
            }) => {
 | 
					            }) => {
 | 
				
			||||||
                println!("Compiled with triple: {}", &triple);
 | 
					                println!("{}", llvm_ir);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                let after = std::time::SystemTime::now();
 | 
				
			||||||
 | 
					                println!("Compiled with triple: {}\n", &triple);
 | 
				
			||||||
                fs::write(&llvm_ir_path, &llvm_ir).expect("Could not write LLVM IR -file!");
 | 
					                fs::write(&llvm_ir_path, &llvm_ir).expect("Could not write LLVM IR -file!");
 | 
				
			||||||
                println!("Output LLVM IR to {:?}", llvm_ir_path);
 | 
					                println!("Output LLVM IR to {:?}", llvm_ir_path);
 | 
				
			||||||
                fs::write(&asm_path, &assembly).expect("Could not write Assembly-file!");
 | 
					                fs::write(&asm_path, &assembly).expect("Could not write Assembly-file!");
 | 
				
			||||||
                println!("Output Assembly to {:?}", asm_path);
 | 
					                println!("Output Assembly to {:?}", asm_path);
 | 
				
			||||||
                fs::write(&object_path, &obj_buffer).expect("Could not write Object-file!");
 | 
					                fs::write(&object_path, &obj_buffer).expect("Could not write Object-file!");
 | 
				
			||||||
                println!("Output Object-file to {:?}", object_path);
 | 
					                println!("Output Object-file to {:?}\n", object_path);
 | 
				
			||||||
 | 
					                println!(
 | 
				
			||||||
                println!("{}", llvm_ir);
 | 
					                    "Compilation took: {:.2}ms\n",
 | 
				
			||||||
 | 
					                    (after.duration_since(before).unwrap().as_micros() as f32) / 1000.
 | 
				
			||||||
 | 
					                );
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            Err(e) => panic!("{}", e),
 | 
					            Err(e) => panic!("{}", e),
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user