Giter Site home page Giter Site logo

Comments (1)

virusdefender avatar virusdefender commented on July 30, 2024

由于CPU调度的原因,进程运行的实际时间一般都是大于CPU时间的,因为进程在运行的时候,以下行为是不会消耗CPU时间的

  • 输入输出以及阻塞等待输入输出
  • sleep
  • 没有得到时间片,进程处于等待状态

如果测试用例数量过多或者系统系统负载过重就会造成运行时间增加。

比如在单核服务器上,一道题有10组测试用例,每组正常运行需要100ms,如果同时运行,最终每个进程的实际运行时间都会是大约1s。如果只有5组测试用例,那么实际运行时间将会是大约500ms。因为只有一个CPU核心,可以认为每个进程轮流去使用,没有使用的时候就会处于等待状态。

如果此题设置时间限制为200ms,那么运行结果就会是超时。因为超时包含CPU时间超时和实际运行时间超时,默认情况下实际运行时间为CPU时间的3倍,也就是最长可以运行600ms,而实际运行达到了1秒以上。只有设置题目的时间限制为400ms以上才不会造成超时,但是这样就失去了时间限制的意义。

如果合并所有的测试用例为一组数据,那么CPU时间和实际运行时间都将为大约1s,这样就不会出现问题了。

from judgeserver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.