Calculate exec time in code

This commit is contained in:
Всеволод 2024-03-03 20:25:40 +03:00
parent 86a88d44b7
commit 25737baf82
2 changed files with 14 additions and 5 deletions

View File

@ -199,6 +199,8 @@ class Job {
var output = '';
var stats = [];
var start_time = new Date().getTime();
const proc = cp.spawn(proc_call[0], proc_call.splice(1), {
env: {
...this.runtime.env_vars,
@ -311,8 +313,11 @@ class Job {
stats = stats[stats.length - 1];
}
var end_time = new Date().getTime();
var exec_time = end_time - start_time;
this.logger.debug(`Last stats:`, stats);
resolve({ stdout, stderr, code, signal, output, stats });
resolve({ stdout, stderr, code, signal, output, stats, exec_time });
});
proc.on('error', err => {
@ -323,8 +328,11 @@ class Job {
stats = stats[stats.length - 1];
}
var end_time = new Date().getTime();
var exec_time = end_time - start_time;
this.logger.debug(`Last stats:`, stats);
reject({ error: err, stdout, stderr, output, stats });
reject({ error: err, stdout, stderr, output, stats, exec_time });
});
});
}

View File

@ -12,13 +12,14 @@ services:
volumes:
- ./data/piston/packages:/piston/packages
environment:
- PISTON_REPO_URL=http://repo:8000/index
- PISTON_REPO_URL=https://github.com/engineer-man/piston/releases/download/pkgs/index
tmpfs:
- /piston/jobs:exec,uid=1000,gid=1000,mode=711
repo: # Local testing of packages
repo:
# Local testing of packages
build: repo
container_name: piston_repo
command: ['--no-build'] # Don't build anything
command: [ '--no-build' ] # Don't build anything
volumes:
- .:/piston