engineer-man / piston

A high performance general purpose code execution engine.
https://emkc.org/run
MIT License
1.95k stars 252 forks source link

handle usage stats #645

Closed vsecoder closed 1 month ago

vsecoder commented 8 months ago

An attempt (like a working one) to add getting execution statistics via time. https://www.man7.org/linux/man-pages/man1/time.1.html

Example:

{
   "run":{
      "stdout":"hello world\n",
      "stderr":"",
      "code":0,
      "signal":null,
      "output":"hello world",
      "stats":{
         "elapsed_time":"0.20s",      <-- Elapsed real time
         "cpu_time":"0.00s / 0.01s",  <-- Total num of CPU-seconds that the process spent in user/kenrel mode
         "max_mem":"9636Kb"           <-- Max resident set size of the process
      },
      "exec_time":221
   },
   "language":"python",
   "version":"3.12.0"
}
Brikaa commented 1 month ago

Closing this PR since usage stats were handled in the newest version of Piston using Isolate. Thanks though!