Raised This Month: $ Target: $400
 0% 

Memory VS CPU usage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 07-29-2009 , 13:12   Memory VS CPU usage
Reply With Quote #1

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.
SnoW is offline
Send a message via MSN to SnoW
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 07-29-2009 , 13:19   Re: Memory VS CPU usage
Reply With Quote #2

Quote:
Originally Posted by SnoW View Post
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
__________________
joaquimandrade is offline
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 07-29-2009 , 13:25   Re: Memory VS CPU usage
Reply With Quote #3

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
__________________
minimiller is offline
Send a message via MSN to minimiller
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 07-29-2009 , 14:46   Re: Memory VS CPU usage
Reply With Quote #4

Quote:
Originally Posted by joaquimandrade View Post
Explain it more
I'm doing a some kind of top. Something similiar to /top15.
Quote:
Originally Posted by joaquimandrade View Post
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.

Last edited by SnoW; 07-29-2009 at 14:55.
SnoW is offline
Send a message via MSN to SnoW
devil001
Member
Join Date: Feb 2008
Old 07-29-2009 , 14:57   Re: Memory VS CPU usage
Reply With Quote #5

I think one double array would be good. I would go for #2.

motd[id][...].

I bet there is another way that is better
__________________
Host Mist - Helping People Say Hello World
Shared | VPS | Dedicated Hosting
Backup-Spot
Secure,Fast and Reliable Offsite Backups
devil001 is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 07-29-2009 , 15:01   Re: Memory VS CPU usage
Reply With Quote #6

Quote:
Originally Posted by SnoW View Post
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
__________________
joaquimandrade is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 07-29-2009 , 15:06   Re: Memory VS CPU usage
Reply With Quote #7

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.
SnoW is offline
Send a message via MSN to SnoW
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 07-29-2009 , 15:11   Re: Memory VS CPU usage
Reply With Quote #8

Quote:
Originally Posted by SnoW View Post
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?
__________________
joaquimandrade is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 07-29-2009 , 15:14   Re: Memory VS CPU usage
Reply With Quote #9

Quote:
Originally Posted by joaquimandrade View Post
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.
SnoW is offline
Send a message via MSN to SnoW
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 07-29-2009 , 15:19   Re: Memory VS CPU usage
Reply With Quote #10

Quote:
Originally Posted by SnoW View Post
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.
__________________
joaquimandrade is offline
Reply



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

Forum Jump


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


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