SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 29/05/2010, 07:08 PM   #11
Sergei
High-roller
 
Sergei's Avatar
 
Join Date: Mar 2008
Location: Slovenia
Posts: 2,916
Reputation: 230
Default Re: [REL] GVar Plugin v1.0

Quote:
Originally Posted by Incognito
...
Hmm, haven't even thought that way, but it seems like a good solution.

----------------------------------------------------------------------
I made some tests now.

Code:
COMMAND:test(playerid,params[])
{
	new tick = GetTickCount();
	for(new i=0; i<100000; i++)
	{
	  SetPVarInt(playerid,"RandomID",i);
	}
	printf("tick #1: %d",GetTickCount() - tick);
	
	tick = GetTickCount();
	for(new i=0; i<100000; i++)
	{
	  GetPVarInt(playerid,"RandomID");
	}
	printf("tick #2: %d",GetTickCount() - tick);
	
	tick = GetTickCount();
	for(new i=0; i<100000; i++)
	{
	  SetGVarInt("RandomID",i);
	}
	printf("tick #3: %d",GetTickCount() - tick);
	
	tick = GetTickCount();
	for(new i=0; i<100000; i++)
	{
	  GetGVarInt("RandomID");
	}
	printf("tick #4: %d",GetTickCount() - tick);
	
	tick = GetTickCount();
	for(new i=0; i<100000; i++)
	{
	  SOMETHING[randomshit] = i;
	}
	printf("tick #5: %d",GetTickCount() - tick);
	
	tick = GetTickCount();
	for(new i=0; i<100000; i++)
	{
	  i = SOMETHING[randomshit];
	}
	printf("tick #6: %d",GetTickCount() - tick);
	return 1;
}

Results:
[20:45:01] tick #1: 38
[20:45:01] tick #2: 33
[20:45:01] tick #3: 102
[20:45:01] tick #4: 100
[20:45:01] tick #5: 12
[20:45:01] tick #6: 2

I don't know anything about plugin programming, but could this be somehow speeded up a bit? GVars seem to be around three times slower than PVars.
__________________
Watch out, scouts everywhere!
Sergei is offline   Reply With Quote
Old 29/05/2010, 08:04 PM   #12
Calgon
Godfather
 
Calgon's Avatar
 
Join Date: Jan 2009
Posts: 6,449
Reputation: 1066
Default Re: [REL] GVar Plugin v1.0

YES! I've been waiting for this for some time! Some seriously excellent work Incognito!

It's a shame about the speed of it, but it's oversee-able seeing as I'll need to be able to call variables externally. Once again, epic work.
__________________
Calgon is offline   Reply With Quote
Old 29/05/2010, 08:21 PM   #13
MPKaboose
High-roller
 
MPKaboose's Avatar
 
Join Date: Mar 2008
Location: Romania, Timisoara
Posts: 1,068
Reputation: 0
Default Re: [REL] GVar Plugin v1.0

A nice release once again, I will sure use this thanks allot
MPKaboose is offline   Reply With Quote
Old 29/05/2010, 09:05 PM   #14
Incognito
Huge Clucker
 
Join Date: May 2006
Posts: 449
Reputation: 487
Default Re: [REL] GVar Plugin v1.0

$ЯĢ: Possibly, but I don't know what accounts for the differences in run time. I'm sure PVars use a different type of implementation that may be more efficient in terms of speed. I could try creating a hash table, which is much faster than the sorted binary tree this plugin currently uses. That should effectively change the complexity for lookups from O(log n) to O(1). However, as your tests revealed, both PVars and GVars were dozens of times slower than arrays, so if you're scripting something that is absolutely time critical (most PAWN scripts aren't), I would recommend not using these functions at all.
Incognito is offline   Reply With Quote
Old 29/05/2010, 09:18 PM   #15
[HUN]Gamestar
Big Clucker
 
Join Date: Aug 2009
Posts: 165
Reputation: 3
Default Re: [REL] GVar Plugin v1.0

-
[HUN]Gamestar is offline   Reply With Quote
Old 29/05/2010, 09:23 PM   #16
Sergei
High-roller
 
Sergei's Avatar
 
Join Date: Mar 2008
Location: Slovenia
Posts: 2,916
Reputation: 230
Default Re: [REL] GVar Plugin v1.0

You forgot half of your idea. Think about getting that value now and I'm sure you will quickly rip it out
__________________
Watch out, scouts everywhere!
Sergei is offline   Reply With Quote
Old 30/05/2010, 12:52 AM   #17
nemesis-
Huge Clucker
 
Join Date: Sep 2009
Location: USA
Posts: 237
Reputation: 65
Default Re: [REL] GVar Plugin v1.0

Quote:
Originally Posted by $ЯĢ
Quote:
Originally Posted by Incognito
...
Hmm, haven't even thought that way, but it seems like a good solution.

----------------------------------------------------------------------
I made some tests now.

Code:
COMMAND:test(playerid,params[])
{
	new tick = GetTickCount();
	for(new i=0; i<100000; i++)
	{
	  SetPVarInt(playerid,"RandomID",i);
	}
	printf("tick #1: %d",GetTickCount() - tick);
	
	tick = GetTickCount();
	for(new i=0; i<100000; i++)
	{
	  GetPVarInt(playerid,"RandomID");
	}
	printf("tick #2: %d",GetTickCount() - tick);
	
	tick = GetTickCount();
	for(new i=0; i<100000; i++)
	{
	  SetGVarInt("RandomID",i);
	}
	printf("tick #3: %d",GetTickCount() - tick);
	
	tick = GetTickCount();
	for(new i=0; i<100000; i++)
	{
	  GetGVarInt("RandomID");
	}
	printf("tick #4: %d",GetTickCount() - tick);
	
	tick = GetTickCount();
	for(new i=0; i<100000; i++)
	{
	  SOMETHING[randomshit] = i;
	}
	printf("tick #5: %d",GetTickCount() - tick);
	
	tick = GetTickCount();
	for(new i=0; i<100000; i++)
	{
	  i = SOMETHING[randomshit];
	}
	printf("tick #6: %d",GetTickCount() - tick);
	return 1;
}

Results:
[20:45:01] tick #1: 38
[20:45:01] tick #2: 33
[20:45:01] tick #3: 102
[20:45:01] tick #4: 100
[20:45:01] tick #5: 12
[20:45:01] tick #6: 2

I don't know anything about plugin programming, but could this be somehow speeded up a bit? GVars seem to be around three times slower than PVars.
Wow. Arrays blow PVar/GVar out of the water.

This plugin is useful but that speed difference is a dealbreaker. I'm better off using get/set/exist property.
nemesis- is offline   Reply With Quote
Old 30/05/2010, 07:31 AM   #18
Sergei
High-roller
 
Sergei's Avatar
 
Join Date: Mar 2008
Location: Slovenia
Posts: 2,916
Reputation: 230
Default Re: [REL] GVar Plugin v1.0

@nemesis99, will you be ever looping 100'000 times over something? Probably no. Looping through 500 players would still take only 0.51ms (0.00051s), and that's like nothing.


@Incognito, when you add additional 'id' parameter ... will it make any difference if you for example put in something with ID 1 or ID 100000 (I mean difference in speed or memory usage or whatever)?
__________________
Watch out, scouts everywhere!
Sergei is offline   Reply With Quote
Old 30/05/2010, 05:52 PM   #19
nemesis-
Huge Clucker
 
Join Date: Sep 2009
Location: USA
Posts: 237
Reputation: 65
Default Re: [REL] GVar Plugin v1.0

Quote:
Originally Posted by $ЯĢ
@nemesis99, will you be ever looping 100'000 times over something? Probably no. Looping through 500 players would still take only 0.51ms (0.00051s), and that's like nothing.
How about not looping at all? You didn't understand what I said.

You've also a lot to learn about efficiency. Read this for starters: Algorithmic Efficiency. While this plugin does have potential gains in the way of memory efficiency, SA:MP servers have bigger worries, namely, CPU utilization.
nemesis- is offline   Reply With Quote
Old 30/05/2010, 06:11 PM   #20
d0
Beta Tester
 
d0's Avatar
 
Join Date: Oct 2007
Location: Germany
Posts: 810
Reputation: 135
Default Re: [REL] GVar Plugin v1.0

Quote:
Originally Posted by nemesis99
Quote:
Originally Posted by $ЯĢ
@nemesis99, will you be ever looping 100'000 times over something? Probably no. Looping through 500 players would still take only 0.51ms (0.00051s), and that's like nothing.
How about not looping at all? You didn't understand what I said.

You've also a lot to learn about efficiency. Read this for starters: Algorithmic Efficiency. While this plugin does have potential gains in the way of memory efficiency, SA:MP servers have bigger worries, namely, CPU utilization.
The only thing you shouldn't do then is using it in onplayerupdate.

It is slower, yes, but it is not that slow that it is not worth using it.

and the good thing is that you can set a gvar in your gamemode and access it in all other scripts.
__________________
<3
d0 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] GVar (Plugin-Free!) Maxips2 Includes 19 29/11/2014 11:40 AM
[HELP] How to use GVar's Swimor Scripting Help 1 25/07/2012 10:16 AM
Problem with Gvar in 0.3d NeyMar96 Scripting Help 4 26/12/2011 12:58 PM
question Gvar NeyMar96 Scripting Help 3 12/09/2011 08:39 PM
[Q] GVar Plugin Vs enum XePloiT Help Archive 3 05/12/2010 07:51 AM


All times are GMT. The time now is 07:21 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.