And also the following functions:clamp( value, min = cellmin, max = cellmax );
max( value1, value2 );
min( value1, value2 );
random( max );
toupper( c );
tolower( c );
swapchars( c );
The functions provided in this include use less CPU and RAM compared to the default ones,random_num(a, b);
random_float(Float:a, Float:b);
str_to_num(const string[]);
unregister_forward(_forwardType, registerId, post=0);
thanks to simplified logic and reduced memory allocation through macros ( when possible ).
More function-like macros and stocks will be added in the future.
Below are the profiling results for each function.
Functions terminated in '_R' are the faster ones provided by this include.
Each instance of flTime below is the ~'time spent' by the function in a different profiling moment.
swapchars_R( 1738272608 );
flTime: 0.000791
flTime: 0.000813
flTime: 0.000801
swapchars( 1738272608 );
flTime: 0.001807
flTime: 0.001838
flTime: 0.001890
toupper_R( 'd' );Result: swapchars_R performed 2.28 times faster than swapchars.
flTime: 0.000381
flTime: 0.000377
flTime: 0.000382
toupper( 'd' );
flTime: 0.009422
flTime: 0.009378
flTime: 0.009560
tolower_R( 'D' );Result: toupper_R performed 24.87 times faster than toupper.
flTime: 0.000377
flTime: 0.000377
flTime: 0.000377
tolower( 'D' );
flTime: 0.009572
flTime: 0.009492
flTime: 0.009444
max_R( 40, 50 );Result: tolower_R performed 25.05 times faster than tolower.
flTime: 0.000377
flTime: 0.000377
flTime: 0.000377
max( 40, 50 );
flTime: 0.001623
flTime: 0.001672
flTime: 0.001585
min_R( 40, 50 );Result: max_R performed 4.2 times faster than max.
flTime: 0.000377
flTime: 0.000377
flTime: 0.000377
min( 40, 50 );
flTime: 0.001596
flTime: 0.001567
flTime: 0.001564
random_R( 50 );Result: min_R performed 4.14 times faster than min.
flTime: 0.000606
flTime: 0.000626
flTime: 0.000608
random( 50 );
flTime: 0.001708
flTime: 0.001689
flTime: 0.001799
clamp_R( 40, 50, 60 );Result: random_R performed 2.78 times faster than random.
flTime: 0.000395
flTime: 0.000377
flTime: 0.000377
clamp( 40, 50, 60 );
flTime: 0.001761
flTime: 0.001702
flTime: 0.001714
--------------------------Result: clamp_R performed 4.51 times faster than clamp.
LATE ADDITIONS
--------------------------
RANDOM_NUM( 25, 75 );
flTime: 0.000621
flTime: 0.000631
flTime: 0.000618
random_num( 25, 75 );
flTime: 0.002598
flTime: 0.002574
flTime: 0.002605
RANDOM_FLOAT( 25.5, 75.5 );Result: RANDOM_NUM performed 4.16 times faster than random_num.
flTime: 0.000628
flTime: 0.000625
flTime: 0.000608
random_float( 25.5, 75.5 );
flTime: 0.002517
flTime: 0.002549
flTime: 0.002614
*CHAR_TO_DIGIT should only be used for a single digit.Result: RANDOM_FLOAT performed 4.13 times faster than random_float.
CHAR_TO_DIGIT( g_szSeven[ 7 ] );new const g_szSeven[ ] = "Number 7";
flTime: 0.000797
flTime: 0.000868
flTime: 0.000855
str_to_num( g_szSeven[ 7 ] );
flTime: 0.004960
flTime: 0.005031
flTime: 0.004981
*UNREG_FM avoids calling the unregister_forward() native on forwards that were already unregistered, which could occur in certain cases.Result: CHAR_TO_DIGIT performed 6.22 times faster than str_to_num.
It does this by automatically clearing the passed handle; then quickly determines if the forward was not already unregistered by checking if the passed handle value is 0.
It has minimal impact in execution time of valid un-registration requests.
UNREG_FM( FM_UpdateClientData, pf_Already_Unregistered, false );
flTime: 0.000378
flTime: 0.000377
flTime: 0.000406
unregister_forward( FM_UpdateClientData, pf_Already_Unregistered, false );
flTime: 0.001887
flTime: 0.001805
flTime: 0.001801
*Profiling results in this page are accurate and were obtained inResult: UNREG_FM performed 4.77 times faster than unregister_forward.
appropriate environment at similar conditions using the same notebook.
*Different computers may obtain lower or higher diffs. than the proportions herein displayed.
*Intel(R) Core(TM)2 Duo T6400 @ 2.00GHz is a Dual-Core processor from 2009.
* Multi-Core processors tend to obtain even higher diffs.
