Skip to content

Commit

Permalink
Add timing logs for server start
Browse files Browse the repository at this point in the history
  • Loading branch information
WillLillis committed Jul 5, 2024
1 parent c88e4f2 commit c28f041
Showing 1 changed file with 56 additions and 20 deletions.
76 changes: 56 additions & 20 deletions src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,51 +90,67 @@ pub fn main() -> Result<()> {
let mut names_to_info = NameToInfoMaps::default();
let params: InitializeParams = serde_json::from_value(initialization_params.clone()).unwrap();
let target_config = get_target_config(&params);
info!("Server Configuration: {:?}", target_config);

// create a map of &Instruction_name -> &Instruction - Use that in user queries
// The Instruction(s) themselves are stored in a vector and we only keep references to the
// former map
let x86_instructions = if target_config.instruction_sets.x86 {
info!("Populating instruction set -> x86...");
let start = std::time::Instant::now();
let xml_conts_x86 = include_str!("../../opcodes/x86.xml");
populate_instructions(xml_conts_x86)?
let instrs = populate_instructions(xml_conts_x86)?
.into_iter()
.map(|instruction| {
// filter out assemblers by user config
instr_filter_targets(&instruction, &target_config)
})
.filter(|instruction| !instruction.forms.is_empty())
.collect()
.collect();
info!(
"x86 instruction set loaded in {}ms",
start.elapsed().as_millis()
);
instrs
} else {
Vec::new()
};

let x86_64_instructions = if target_config.instruction_sets.x86_64 {
info!("Populating instruction set -> x86_64...");
let start = std::time::Instant::now();
let xml_conts_x86_64 = include_str!("../../opcodes/x86_64.xml");
populate_instructions(xml_conts_x86_64)?
let instrs = populate_instructions(xml_conts_x86_64)?
.into_iter()
.map(|instruction| {
// filter out assemblers by user config
instr_filter_targets(&instruction, &target_config)
})
.filter(|instruction| !instruction.forms.is_empty())
.collect()
.collect();
info!(
"z86-64 Instruction set loaded in {}ms",
start.elapsed().as_millis()
);
instrs
} else {
Vec::new()
};

let z80_instructions = if target_config.instruction_sets.z80 {
info!("Populating instruction set -> z80...");
let start = std::time::Instant::now();
let xml_conts_z80 = include_str!("../../opcodes/z80.xml");
populate_instructions(xml_conts_z80)?
let instrs = populate_instructions(xml_conts_z80)?
.into_iter()
.map(|instruction| {
// filter out assemblers by user config
instr_filter_targets(&instruction, &target_config)
})
.filter(|instruction| !instruction.forms.is_empty())
.collect()
.collect();
info!(
"z80 instruction set loaded in {}ms",
start.elapsed().as_millis()
);
instrs
} else {
Vec::new()
};
Expand All @@ -159,31 +175,46 @@ pub fn main() -> Result<()> {
// The Register(s) themselves are stored in a vector and we only keep references to the
// former map
let x86_registers = if target_config.instruction_sets.x86 {
info!("Populating register set -> x86...");
let start = std::time::Instant::now();
let xml_conts_regs_x86 = include_str!("../../registers/x86.xml");
populate_registers(xml_conts_regs_x86)?
let regs = populate_registers(xml_conts_regs_x86)?
.into_iter()
.collect()
.collect();
info!(
"x86 register set loaded in {}ms",
start.elapsed().as_millis()
);
regs
} else {
Vec::new()
};

let x86_64_registers = if target_config.instruction_sets.x86_64 {
info!("Populating register set -> x86_64...");
let start = std::time::Instant::now();
let xml_conts_regs_x86_64 = include_str!("../../registers/x86_64.xml");
populate_registers(xml_conts_regs_x86_64)?
let regs = populate_registers(xml_conts_regs_x86_64)?
.into_iter()
.collect()
.collect();
info!(
"x86-64 register set loaded in {}ms",
start.elapsed().as_millis()
);
regs
} else {
Vec::new()
};

let z80_registers = if target_config.instruction_sets.z80 {
info!("Populating register set -> z80...");
let start = std::time::Instant::now();
let xml_conts_regs_z80 = include_str!("../../registers/z80.xml");
populate_registers(xml_conts_regs_z80)?
let regs = populate_registers(xml_conts_regs_z80)?
.into_iter()
.collect()
.collect();
info!(
"z80 register set loaded in {}ms",
start.elapsed().as_millis()
);
regs
} else {
Vec::new()
};
Expand All @@ -197,9 +228,14 @@ pub fn main() -> Result<()> {
populate_name_to_register_map(Arch::Z80, &z80_registers, &mut names_to_info.registers);

let gas_directives = if target_config.assemblers.gas {
info!("Populating directive set -> Gas...");
let start = std::time::Instant::now();
let xml_conts_gas = include_str!("../../directives/gas_directives.xml");
populate_directives(xml_conts_gas)?.into_iter().collect()
let dirs = populate_directives(xml_conts_gas)?.into_iter().collect();
info!(
"Gas directive set loaded in {}ms",
start.elapsed().as_millis()
);
dirs
} else {
Vec::new()
};
Expand Down

0 comments on commit c28f041

Please sign in to comment.