Page 1 of 1

Module: Execution Time v1.0 [Linux + Windows]

Posted: Tue Oct 20, 2026 5:21 am
by Archive-Poster
Execution Time
1.0

Informations

♠ You will be able to view how much time a function take.

Header File

Code: Select all

/* Counts by now */
native Execution_Time_Stick( );

/* Returns time counted, float inside string */
/* Do not exceed 128 characters */
/* 16 characters is a good value to use */
native Execution_Time_Return( String[ ], Length );

/* Transforms float inside string in pure float */
stock Float: Execution_Time_Return_Float( String[ ] )
    return str_to_float( String );
Example of Plugin

Code: Select all

#include < amxmodx >
#include < execution_time >

new g_String[ 16 ];

public plugin_init( ) {
    Execution_Time_Stick( );

    for( new i = 0; i < 24000; i++ )
        server_print( "1 + 1 = 2" );

    Execution_Time_Return( g_String, charsmax( g_String ) );

    server_print( "Printing 24,000 lines to server's console took %f seconds!", Execution_Time_Return_Float( g_String ) );

    Execution_Time_Stick( );

    for( new i = 0; i < 12000; i++ )
        server_print( "1 + 1 = 2" );

    Execution_Time_Return( g_String, charsmax( g_String ) );

    server_print( "Printing 12,000 lines to server's console took %f seconds!", Execution_Time_Return_Float( g_String ) );
} 
Function to Remove Unused Zeros

Code: Select all

/*
  Input: "0.200000"
  Output: "0.2"
*/

Remove_Unused_Zeros( String[ ] ) {
  for( new Iterator = strlen( String ) - 1; Iterator >= 2; Iterator-- ) {
    if( String[ Iterator ] == '0' ) {
      if( String[ Iterator - 1 ] == '.' )
        break;

      else
        String[ Iterator ] = '^0';
    }
  }
}