Giter Site home page Giter Site logo

kelab / code-runner Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 0.0 644 KB

一个判题沙箱;可根据判题数据,判定用户程序的运行结果以及获取用户程序运行时间和内存消耗、可隔离程序网络。

Home Page: https://github.com/Kelab/code-runner/tree/main/docs

License: MIT License

Makefile 3.05% C 96.90% JavaScript 0.05%
online-judge judge-system judger code-runner code-sandbox

code-runner's Introduction

code-runner

一个运行用户程序的工具。

根据判题数据,判定用户程序的运行结果以及获取用户程序运行时间和内存消耗。

判题结果会以 JSON 格式输出到标准输出中。

{
  "status": 0,
  "cpu_time_used": 2,
  "cpu_time_used_us": 1870,
  "real_time_used": 15,
  "real_time_used_us": 14849,
  "memory_used": 1516,
  "error_code": 0,
  "signal_code": 0,
  "exit_code": 0
}

文档

查看文档:https://code-runner.kelab.dev

致谢

项目中使用到的开源库链接:

参考、使用、改写了以下项目的部分代码:

感谢上述提到的所有仓库以及开发人员。

code-runner's People

Contributors

bytemain avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

code-runner's Issues

exit failure when diff error

when user_out_file is not a valid file, the check stage will alert error, but exit code always zero,

2021-02-27 22:38:39 DEBUG src/run.c:187: child process exit normal
2021-02-27 22:38:39 ERROR src/diff.c:31: lseek userout_len failure: Bad file descriptor
2021-02-27 22:38:39 INFO  src/judge.c:78: {
  "status": 8,
  "cpu_time_used": 3,
  "cpu_time_used_us": 3368,
  "real_time_used": 6,
  "real_time_used_us": 5840,
  "memory_used": 14628,
  "signal": 0,
  "exit_code": 0
}

完善共享库的使用方法

libjudge.so 如何使用

from ctypes import *

handle = cdll.LoadLibrary("./libjudge.so")
func = handle.main

func.restype = c_int
func.argtypes = c_int, POINTER(c_char_p)
# b"./test", b"1000", b"2048", b"1.in", b"1.out", b"1.tmp.out", b"1.log"
args = (c_char_p * 10)(
    b"judge",
    b"judge",
    b"./main",
    b"1000",
    b"2048",
    b"./tests/1/1.in",
    b"./tests/1/1.out",
    b"1.tmp.out",
    b"-l",
    b"1.log",
)
tmp = func(len(args), args)
print(tmp)

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.