Struct emjudge_judgecore::settings::Settings
source · pub struct Settings {
pub compile_setting: CompileSetting,
pub run_setting: RunSetting,
}
Fields§
§compile_setting: CompileSetting
§run_setting: RunSetting
Implementations§
source§impl Settings
impl Settings
sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/test_memorylimit_exceed.rs (line 7)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
fn main() {
let settings = settings::Settings::new();
let compiler = compile::Compiler::new(&settings.compile_setting);
let mut script = vec![];
let input = vec![];
File::open("examples/programs/mle.cpp").unwrap().read_to_end(&mut script).unwrap();
println!("Compiling...");
match compiler.compile(&String::from("C++"), &script) {
compile::CompileResult::OK(executable_script) => {
println!("Finish");
println!("Running...");
let runner = run::StandardRunner::new(&settings::RunSetting{memory_limit_KB: 1024 * 1024, cpu_limit_ms: 1000, dir: settings.run_setting.dir});
println!("{:?}", runner.run(&executable_script, &input));
},
compile::CompileResult::CompileError(result) => {
println!("Compile Error:\n{}", result);
}
compile::CompileResult::NoSuchLanguage => {
println!("Compile Error:\n{}", "No such language");
}
}
}
More examples
examples/test_timelimit_exceed.rs (line 6)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
fn main() {
let settings = settings::Settings::new();
let compiler = compile::Compiler::new(&settings.compile_setting);
let mut script = vec![];
let input = vec![];
File::open("examples/programs/loop.cpp").unwrap().read_to_end(&mut script).unwrap();
println!("Compiling...");
match compiler.compile(&String::from("C++"), &script) {
compile::CompileResult::OK(executable_script) => {
println!("Finish");
println!("Running...");
let runner = run::StandardRunner::new(&settings::RunSetting{memory_limit_KB: 1024 * 1024, cpu_limit_ms: 5000, dir: settings.run_setting.dir});
println!("{:?}", runner.run(&executable_script, &input));
},
compile::CompileResult::CompileError(result) => {
println!("Compile Error:\n{}", result);
}
compile::CompileResult::NoSuchLanguage => {
println!("Compile Error:\n{}", "No such language");
}
}
}
examples/test_helloworld.rs (line 7)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
fn main() {
let settings = settings::Settings::new();
let compiler = compile::Compiler::new(&settings.compile_setting);
let mut script = vec![];
let input = vec![];
File::open("examples/programs/helloworld.cpp").unwrap().read_to_end(&mut script).unwrap();
println!("Compiling...");
match compiler.compile(&String::from("C++"), &script) {
compile::CompileResult::OK(executable_script) => {
println!("Finish");
println!("Running...");
let runner = run::StandardRunner::new(&settings::RunSetting{memory_limit_KB: 1024 * 1024, cpu_limit_ms: 1000, dir:settings.run_setting.dir});
let result = runner.run(&executable_script, &input);
println!("{:?}", result);
if let RunResult::OK(_, result) = result {
println!("output is:{:?}", String::from_utf8_lossy(&result));
}
},
compile::CompileResult::CompileError(result) => {
println!("Compile Error:\n{}", result);
}
compile::CompileResult::NoSuchLanguage => {
println!("Compile Error:\n{}", "No such language");
}
}
}
examples/test_1plusto100.rs (line 7)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
fn main() {
let settings = settings::Settings::new();
let compiler = compile::Compiler::new(&settings.compile_setting);
let runner = run::StandardRunner::new(&RunSetting{memory_limit_KB: 1024 * 1024, cpu_limit_ms: 10000, dir: settings.run_setting.dir.clone()});
let mut eval_script = vec![];
let mut test_out = vec![];
let mut input = vec![];
let mut output = vec![];
File::open("examples/programs/1plusto100/eval.cpp").unwrap().read_to_end(&mut eval_script).unwrap();
File::open("examples/programs/1plusto100/in").unwrap().read_to_end(&mut input).unwrap();
File::open("examples/programs/1plusto100/out").unwrap().read_to_end(&mut output).unwrap();
File::open("examples/programs/1plusto100/testout").unwrap().read_to_end(&mut test_out).unwrap();
println!("Compiling eval...");
let compile_eval = compiler.compile(&String::from("C++"), &eval_script);
println!("Finish");
if let CompileResult::OK(exe_eval) = compile_eval {
println!("Testing...");
let tester = test::AnwserTester::new(&runner, &exe_eval);
println!("Finish: {:?}", tester.single_test(&input, &test_out, &output));
}
}
examples/test_aplusb.rs (line 7)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
fn main() {
let settings = settings::Settings::new();
let compiler = compile::Compiler::new(&settings.compile_setting);
let runner = run::StandardRunner::new(&RunSetting{memory_limit_KB: 1024 * 1024, cpu_limit_ms: 10000, dir: settings.run_setting.dir.clone()});
let mut eval_script = vec![];
let mut test_script = vec![];
let mut input = vec![];
let mut output = vec![];
File::open("examples/programs/aplusb/eval.cpp").unwrap().read_to_end(&mut eval_script).unwrap();
File::open("examples/programs/aplusb/main.cpp").unwrap().read_to_end(&mut test_script).unwrap();
File::open("examples/programs/aplusb/in").unwrap().read_to_end(&mut input).unwrap();
File::open("examples/programs/aplusb/out").unwrap().read_to_end(&mut output).unwrap();
println!("Compiling eval...");
let compile_eval = compiler.compile(&String::from("C++"), &eval_script);
println!("Finish");
if let CompileResult::OK(exe_eval) = compile_eval {
println!("Compiling test...");
let compile_test = compiler.compile(&String::from("C++"), &test_script);
println!("Finish");
if let CompileResult::OK(exe_test) = compile_test {
println!("Testing...");
let tester = test::StandardTester::new(&runner, &runner, &exe_test, &exe_eval);
println!("Finish: {:?}", tester.single_test(&input, &output));
}
}
}
Trait Implementations§
source§impl<'de> Deserialize<'de> for Settings
impl<'de> Deserialize<'de> for Settings
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl RefUnwindSafe for Settings
impl Send for Settings
impl Sync for Settings
impl Unpin for Settings
impl UnwindSafe for Settings
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more