Skip to content

Commit

Permalink
Hz speed
Browse files Browse the repository at this point in the history
  • Loading branch information
DEntisT committed Jan 4, 2024
1 parent 8b1aba5 commit 7675215
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 3 deletions.
21 changes: 20 additions & 1 deletion doc/sysval.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,23 @@ Return type: `int`

Return type: `int`

- Returns 1 if the build is beta and 0 if the build is stable.
- 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
}
```
7 changes: 6 additions & 1 deletion src/modules/header.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
////////////////
Expand Down
1 change: 1 addition & 0 deletions src/modules/interpreter.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
7 changes: 7 additions & 0 deletions src/pawnscript.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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;
}

Expand Down
4 changes: 3 additions & 1 deletion src/ps_mem.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -524,4 +524,6 @@ new dpp_kwords[dpp_maxkwords][256] = {
new dpp_interval__;
new dpp_repeat__=1;
//-----------------------------------------------------------
new dpp_deprecated__=1;
new dpp_deprecated__=1;
//-----------------------------------------------------------
new dpp_speedhz=0;

0 comments on commit 7675215

Please sign in to comment.