From 767521544b8b2389d4967f20cab887792cc2571f Mon Sep 17 00:00:00 2001 From: DEntisT Date: Thu, 4 Jan 2024 13:32:19 +0100 Subject: [PATCH] Hz speed --- doc/sysval.md | 21 ++++++++++++++++++++- src/modules/header.inc | 7 ++++++- src/modules/interpreter.inc | 1 + src/pawnscript.pwn | 7 +++++++ src/ps_mem.pwn | 4 +++- 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/doc/sysval.md b/doc/sysval.md index 1ec2a30..6c47a8b 100644 --- a/doc/sysval.md +++ b/doc/sysval.md @@ -41,4 +41,23 @@ Return type: `int` Return type: `int` -- Returns 1 if the build is beta and 0 if the build is stable. \ No newline at end of file +- Returns 1 if the build is beta and 0 if the build is stable. + + +## `__procspeed` + +Return type: `int` + +- Returns the current process execution speed (how many times was the interpreter core function called in this second) in hertz. + + +```cpp +@task + this->interval=1000 +void supercooltask() public +{ + new.int,process_speed=__procspeed + console.println.log("Process execution speed: {process_speed} Hz") + #undef:process_speed +} +``` \ No newline at end of file diff --git a/src/modules/header.inc b/src/modules/header.inc index 9de8b9d..135250f 100644 --- a/src/modules/header.inc +++ b/src/modules/header.inc @@ -776,7 +776,12 @@ stock dpp_argsystemval(arg[]) { format(newvalue, sizeof newvalue, "%i", DPP_VERSION_BETA); strmid(arg, newvalue, 0, dpp_argcharsize, dpp_argcharsize); - } + } + if(!strcmp(arg, "__procspeed")) + { + format(newvalue, sizeof newvalue, "%i", dpp_speedhz); + strmid(arg, newvalue, 0, dpp_argcharsize, dpp_argcharsize); + } return 1; } //////////////// diff --git a/src/modules/interpreter.inc b/src/modules/interpreter.inc index fbd193d..c067421 100644 --- a/src/modules/interpreter.inc +++ b/src/modules/interpreter.inc @@ -24,6 +24,7 @@ new varsetgroup[2][64]; stock dpp_process(line[]) { + dpp_speedhz = dpp_speedhz + 1; #if DPP_LOGPROCESSES == 1 if(dpp_processfunc != dpp_lastvalueprcfunc) { diff --git a/src/pawnscript.pwn b/src/pawnscript.pwn index bc513dc..4226b85 100644 --- a/src/pawnscript.pwn +++ b/src/pawnscript.pwn @@ -81,6 +81,11 @@ native fcreatedir(const filename[]); #include "components/vector.inc" //----------------------------------------------------------- +dpp_resspeedhz(); public dpp_resspeedhz() +{ + dpp_speedhz = 0; + return 1; +} dpp_main(); public dpp_main() { @@ -89,6 +94,8 @@ dpp_main(); public dpp_main() dpp_nullcomment(); dpp_compile("index"SCRIPT_EXT); SetTimer("main_again", 3000, false); + SetTimer("dpp_resspeedhz",1000,true); + return 1; } diff --git a/src/ps_mem.pwn b/src/ps_mem.pwn index bb635de..31c86a5 100644 --- a/src/ps_mem.pwn +++ b/src/ps_mem.pwn @@ -524,4 +524,6 @@ new dpp_kwords[dpp_maxkwords][256] = { new dpp_interval__; new dpp_repeat__=1; //----------------------------------------------------------- -new dpp_deprecated__=1; \ No newline at end of file +new dpp_deprecated__=1; +//----------------------------------------------------------- +new dpp_speedhz=0; \ No newline at end of file