03.07.2011, 17:30
- English translation by JoJLlmAn.
Running System
CPU: Intel Pentium Dual T2370
OS: Windows 7
SA:MP: v0.3c R2
Java: JDK6 Update 24 (Java HotSpot Server VM)
Timing Code
Java:
Pawn:
Performance of calling Native function
Java: 28ms.
Pawn: 70ms.
Performance of calling Native function (with strings)
Java: 291ms.
Pawn: 116ms.
Performance of calculating primes
Java: 77ms.
Pawn: 590ms.
Summary
In performance of calling native, java is 2.5 times faster than pawn.
The other one with strings, pawn is 2.5 times faster*
In calculating primes, java is 7.5 times faster**
*for reference only, maybe the Windows codepage conversion(UTF16->MBCS) slows it. more complicated the string is, more difference between them.
**for reference only, depends on what algorithm you use.
Running System
CPU: Intel Pentium Dual T2370
OS: Windows 7
SA:MP: v0.3c R2
Java: JDK6 Update 24 (Java HotSpot Server VM)
Timing Code
Java:
Код:
long lastTick = System.nanoTime(); // Put the code you want to count time long time = System.nanoTime() - lastTick; System.out.println( "Java: " + time/1000/1000 + " ms." );
Код:
new lastTick = GetTickCount(); // Put the code you want to count time new Time = GetTickCount() - lastTick; printf( "Pawn: %d ms.", Time );
Java: 28ms.
Код:
for( int i=0; i<1000000; i++ ) this.allowAdminTeleport(true);
Код:
for( new i=0; i<1000000; i++ ) AllowAdminTeleport(1);
Java: 291ms.
Код:
for( int i=0; i<100000; i++ ) this.setGameModeText( "Shoebill" );
Код:
for( new i=0; i<100000; i++ ) SetGameModeText( "Shoebill" );
Java: 77ms.
Код:
boolean isPrime( int num ) { int divisor = 3, limit = num; if( num%2 == 0 ) return false; while( limit > divisor ) { if( num%divisor == 0 ) return false; limit = num / divisor; divisor += 2; } return true; } for( int i=0; i<100; i++ ) isPrime(2147483647);
Код:
isPrime( num ) { new divisor = 3, limit = num; if( num%2 == 0 ) return 0; while( limit > divisor ) { if( num%divisor == 0 ) return 0; limit = num / divisor; divisor += 2; } return 1; } for( new i = 0; i < 100; i++ ) isPrime(2147483647);
In performance of calling native, java is 2.5 times faster than pawn.
The other one with strings, pawn is 2.5 times faster*
In calculating primes, java is 7.5 times faster**
*for reference only, maybe the Windows codepage conversion(UTF16->MBCS) slows it. more complicated the string is, more difference between them.
**for reference only, depends on what algorithm you use.