AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Memory VS CPU usage (https://forums.alliedmods.net/showthread.php?t=98803)

SnoW 07-29-2009 13:12

Memory VS CPU usage
 
Let's say I'm making a plugin that would use 14 different kind of motds. So which is the best way?
1# Make a 14 times 2536 array and make the motds once.
2# Always when a player wants to see one motd, do it and destroy the variable.

The motds are showed as often as you would watch /rankstats. Also note that when making a motd the plugin reads throw all players' datas from a file. So I need your opinions.

joaquimandrade 07-29-2009 13:19

Re: Memory VS CPU usage
 
Quote:

Originally Posted by SnoW (Post 884955)
Let's say I'm making a plugin that would use 14 different kind of motds. So which is the best way?
1# Make a 14 times 2536 array and make the motds once.
2# Always when a player wants to see one motd, do it and destroy the variable.

The motds are showed as often as you would watch /rankstats. Also note that when making a motd the plugin reads throw all players' datas from a file. So I need your opinions.

#1 and I suppose you shouldn't be reading from the file on motd display. I can be wrong. Explain it more

minimiller 07-29-2009 13:25

Re: Memory VS CPU usage
 
if you choose option #2 and 2 players try to open different MOTDS at the same time, your server might kerplode (joke. but i dunno what would happen)

i personally would go for #1

SnoW 07-29-2009 14:46

Re: Memory VS CPU usage
 
Quote:

Originally Posted by joaquimandrade (Post 884964)
Explain it more

I'm doing a some kind of top. Something similiar to /top15.
Quote:

Originally Posted by joaquimandrade (Post 884964)
I suppose you shouldn't be reading from the file on motd display. I can be wrong.

#1 is to make the information to memory and #2 to read it again all the time when needed. There's no other options.

devil001 07-29-2009 14:57

Re: Memory VS CPU usage
 
I think one double array would be good. I would go for #2.

motd[id][...].

I bet there is another way that is better

joaquimandrade 07-29-2009 15:01

Re: Memory VS CPU usage
 
Quote:

Originally Posted by SnoW (Post 885025)
I'm doing a some kind of top. Something similiar to /top15.

#1 is to make the information to memory and #2 to read it again all the time when needed. There's no other options.

I got you wrong about the file reading. But there are more options. The list is:

You can read all the data to memory on map start.
You can read, on each player first join, his data and keep it in memory.
You can read the needed player data when the command is issued.

Still, I can be wrong because "some kind of top" is too vague

SnoW 07-29-2009 15:06

Re: Memory VS CPU usage
 
Ye, your 2nd isn't possible, since the top is from all players ever played on the server, not just players who played the current map. Like I already said you could compare this to "/top15" command.

joaquimandrade 07-29-2009 15:11

Re: Memory VS CPU usage
 
Quote:

Originally Posted by SnoW (Post 885043)
Ye, your 2nd isn't possible, since the top is from all players ever played on the server, not just players who played the current map. Like I already said you could compare this to "/top15" command.

But if you do it like #1, how will you keep the data updated?

SnoW 07-29-2009 15:14

Re: Memory VS CPU usage
 
Quote:

Originally Posted by joaquimandrade (Post 885050)
But if you do it like #1, how will you keep the data updated?

It gets updated every map change. I believe that's more than enough.

joaquimandrade 07-29-2009 15:19

Re: Memory VS CPU usage
 
Quote:

Originally Posted by SnoW (Post 885053)
It gets updated every map change. I believe that's more than enough.

It depends on your top. I remember seeing tops related to speed and in those it would make sense more update. But if your is really like top 15 then you are done with #1.


All times are GMT -4. The time now is 18:27.

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