Skip to main content
The ExecutionResult model represents the outcome of a code execution operation. It contains the program output, exit code, and execution time metrics.

Fields

output
string
The combined standard output (stdout) and standard error (stderr) from the executed code. This contains all text printed or logged by the program during execution.
exitCode
int
The exit code from the Docker container execution. Currently, this value is always set to 0 in the implementation, regardless of whether the code compiled or executed successfully. Check the output field for compilation errors or runtime exceptions.
executionTime
long
The total time taken to execute the code, measured in milliseconds. This includes the time to start the Docker container, run the code, and capture the output.

Example

Successful execution

{
  "output": "Hello, World!\n",
  "exitCode": 0,
  "executionTime": 1234
}

Execution with error

{
  "output": "Traceback (most recent call last):\n  File \"main.py\", line 1, in <module>\n    print(undefined_variable)\nNameError: name 'undefined_variable' is not defined\n",
  "exitCode": 0,
  "executionTime": 856
}

Java class

This model is defined in the backend as:
package com.runtime.model;

public class ExecutionResult {
    private String output;
    private int exitCode;
    private long executionTime;

    public ExecutionResult(String output, int exitCode, long executionTime) {
        this.output = output;
        this.exitCode = exitCode;
        this.executionTime = executionTime;
    }

    // Getters and setters
    public String getOutput() { return output; }
    public void setOutput(String output) { this.output = output; }
    
    public int getExitCode() { return exitCode; }
    public void setExitCode(int exitCode) { this.exitCode = exitCode; }
    
    public long getExecutionTime() { return executionTime; }
    public void setExecutionTime(long executionTime) { this.executionTime = executionTime; }
}

Usage

The ExecutionResult is wrapped in an ApiResponse<ExecutionResult> when returned from the /api/execute endpoint. See the Execute Code endpoint documentation for complete response examples.
The execution time includes container startup overhead. Subsequent executions may be faster due to Docker image caching.

Build docs developers (and LLMs) love