JudgeLib

JudgeLib NPM Library

A distributed code-execution library that divides large test cases into batches, stores them in Redis, and executes them efficiently using background workers.

npm install lib-judge

Why Use JudgeLib?

Batch Processing

JudgeLib divides large sets of test cases into smaller, manageable batches for faster and more efficient execution.

Redis Integration

Test cases and execution data are stored and managed in Redis for fast retrieval and distributed coordination.

Worker System

Background workers fetch batched test cases from Redis and execute them in isolated environments for maximum reliability.

Installation & Setup

1Install Package
Add JudgeLib to your Node.js project

Using npm

npm install lib-judge

Using yarn

yarn add lib-judge
2How It Works
JudgeLib automatically batches and processes your test cases

Example Usage

import { judge } from 'lib-judge';

// Sample testcases input
const input = '5 1 2 3 4 5 ### 3 10 20 30 ### 4 2 2 2 2';
const output = '15 ### 60 ### 8';

const result = await judge({
  codePath: tmpPath, //path of the file
  ques_name: 'sum of array',
  input,
  output,
  language: 'cpp',
  timeout: '2',
  sizeout: '64'
});

// Internally:
// 1️⃣ Input is divided into batches
// 2️⃣ Stored in Redis
// 3️⃣ Workers pull batches and execute them asynchronously
console.log(result);

Supported Languages

Python

3.11

.py

Java

17

.java

C++

GCC 11

.cpp