From 9826ecc6784df8630a6f5b7ef8461f280a43981c Mon Sep 17 00:00:00 2001 From: LiYang Date: Mon, 22 May 2017 22:12:17 +0800 Subject: [PATCH] only calculate user space cpu time --- src/runner.c | 4 +--- tests/Python_and_core/testcase/integration/test.py | 9 ++++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/runner.c b/src/runner.c index d4fffec..35c3735 100644 --- a/src/runner.c +++ b/src/runner.c @@ -96,9 +96,7 @@ void run(struct config *_config, struct result *_result) { _result->exit_code = WEXITSTATUS(status); _result->cpu_time = (int) (resource_usage.ru_utime.tv_sec * 1000 + - resource_usage.ru_utime.tv_usec / 1000 + - resource_usage.ru_stime.tv_sec * 1000 + - resource_usage.ru_stime.tv_usec / 1000); + resource_usage.ru_utime.tv_usec / 1000); _result->memory = resource_usage.ru_maxrss * 1024; // get end time diff --git a/tests/Python_and_core/testcase/integration/test.py b/tests/Python_and_core/testcase/integration/test.py index bba3980..50f129d 100644 --- a/tests/Python_and_core/testcase/integration/test.py +++ b/tests/Python_and_core/testcase/integration/test.py @@ -260,13 +260,12 @@ class IntegrationTest(base.BaseTestCase): def test_gcc_random(self): config = self.base_config + config["max_memory"] = _judger.UNLIMITED config["exe_path"] = "/usr/bin/gcc" config["args"] = ["../test_src/integration/gcc_random.c", "-o", os.path.join(self.workspace, "gcc_random")] result = _judger.run(**config) - self.assertEqual(result["result"], _judger.RESULT_CPU_TIME_LIMIT_EXCEEDED) - self.assertTrue(result["cpu_time"] >= 1950) - self.assertTrue(result["real_time"] >= 1950) + self.assertTrue(result["real_time"] >= 2000) def test_cpp_meta(self): config = self.base_config @@ -276,8 +275,8 @@ class IntegrationTest(base.BaseTestCase): "-o", os.path.join(self.workspace, "cpp_meta")] result = _judger.run(**config) self.assertEqual(result["result"], _judger.RESULT_CPU_TIME_LIMIT_EXCEEDED) - self.assertTrue(result["cpu_time"] >= 1950) - self.assertTrue(result["real_time"] >= 1950) + self.assertTrue(result["cpu_time"] > 1500) + self.assertTrue(result["real_time"] >= 2000) def test_output_size(self): config = self.base_config