AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Module Coding (https://forums.alliedmods.net/forumdisplay.php?f=9)
-   -   Module: Execution Time v1.0 [Linux + Windows] (https://forums.alliedmods.net/showthread.php?t=199947)

claudiuhks 11-03-2012 09:35

Module: Execution Time v1.0 [Linux + Windows]
 
4 Attachment(s)
Execution Time
1.0




Informations

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

Header File

Code:
/* 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

PHP Code:

#include < amxmodx >
#include < execution_time >

new g_String16 ];

public 
plugin_init( ) {
    
Execution_Time_Stick( );

    for( new 
024000i++ )
        
server_print"1 + 1 = 2" );

    
Execution_Time_Returng_Stringcharsmaxg_String ) );

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

    
Execution_Time_Stick( );

    for( new 
012000i++ )
        
server_print"1 + 1 = 2" );

    
Execution_Time_Returng_Stringcharsmaxg_String ) );

    
server_print"Printing 12,000 lines to server's console took %f seconds!"Execution_Time_Return_Floatg_String ) );


Function to Remove Unused Zeros

PHP Code:

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

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

      else
        
StringIterator ] = '^0';
    }
  }



Arkshine 11-03-2012 09:50

Re: Module: Execution Time v1.0
 
The profiler of sawce can do that already. What is the difference ?

claudiuhks 11-03-2012 09:55

Re: Module: Execution Time v1.0
 
Quote:

Originally Posted by Arkshine (Post 1831758)
The profiler of sawce can do that already. What is the difference ?

It returns the execution time of a public. Or of how many native calls you have in that public.
It's an AMX Mod X module.

yokomo 11-03-2012 09:57

Re: Module: Execution Time v1.0
 
Can this module record how long it takes for 1 player to kill 5 enemies?

For example:
Player spawn - Execution_Time_Stick( );
if (kill >= 5)
Execution_Time_Return( g_String, charsmax( g_String ) );

***Edited***
Nevermind, it was public.

bibu 11-03-2012 11:37

Re: Module: Execution Time v1.0
 
Thanks, this can be very useful.

claudiuhks 11-03-2012 11:42

Re: Module: Execution Time v1.0
 
Quote:

Originally Posted by yokomo (Post 1831762)
Can this module record how long it takes for 1 player to kill 5 enemies?

For example:
Player spawn - Execution_Time_Stick( );
if (kill >= 5)
Execution_Time_Return( g_String, charsmax( g_String ) );

***Edited***
Nevermind, it was public.

Yes, yokomo. But just one player.

micapat 11-03-2012 11:45

Re: Module: Execution Time v1.0
 
Maybe you can create a system with multiple timers ?

claudiuhks 11-03-2012 11:52

Re: Module: Execution Time v1.0
 
Quote:

Originally Posted by micapat (Post 1831805)
Maybe you can create a system with multiple timers ?

Sorry, give me more details. What do you mean with a timer? A task with forward? Like AMX Mod X main extension has?

Arkshine 11-03-2012 11:54

Re: Module: Execution Time v1.0
 
Quote:

Originally Posted by claudiuhks (Post 1831761)
It returns the execution time of a public. Or of how many native calls you have in that public.

Not sure to understand "time of a public".
If the purpose is to measure time of a chunk of code, sawce's profiler has 2 natives to do that.
Just wanted to know what is the difference, except the fact this one is a module, which is irrelevant.

claudiuhks 11-03-2012 11:58

Re: Module: Execution Time v1.0
 
Quote:

Originally Posted by Arkshine (Post 1831813)
Not sure to understand "time of a public".
If the purpose is to measure time of a chunk of code, sawce's profiler has 2 natives to do that.
Just wanted to know what is the difference, except the fact this one is a module, which is irrelevant.

I mean, the time taken by the bunch of natives existing into a forward.


All times are GMT -4. The time now is 00:06.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.