@Viscount S: i understand that you guys wish to keep memory usage low, but you wouldn't even sacrifice a couple of mb's at max (and not even that much if done correctly) of memory for a much better structure? Memory in this situation should not even be considered. For example you saying Millions of Dialog instances can be created, while that is possible if someone decided to spam a million packets to talk to an NPC, and that's even if you have not handled it to even have a delay or check if he's already interacting with an NPC, then yes. But that's not going to happen?
@CptSky: sorry, i don't know much about .net and/or it's collections but you get the point.
I get fussy about memory issues. Just because the GC handles memory compaction, that means that we should not care about memory and performance.
Also a switch statement isn't a series of if elses, it is more of a goto table:
@Viscount S: i understand that you guys wish to keep memory usage low, but you wouldn't even sacrifice a couple of mb's at max (and not even that much if done correctly) of memory for a much better structure? Memory in this situation should not even be considered. For example you saying Millions of Dialog instances can be created, while that is possible if someone decided to spam a million packets to talk to an NPC, and that's even if you have not handled it to even have a delay or check if he's already interacting with an NPC, then yes. But that's not going to happen?
@CptSky: sorry, i don't know much about .net and/or it's collections but you get the point.
Do you even understand the concept of memory usage and how it works with creating new instances and switch statements?
i don't understand a **** of what you guys are talking about, but just keep up the good work :P, and can someone tell me how far the progress of the server is in %? tnx
Is the source ready yet?
We're basicly far enough to launch a beta, we're just fixing up little things.
How long will the beta last?
Till the summer.
What will happen then?
We will switch to native C++ instead.
How long will that take?
We have already done the dataserver and the defender. I'm currently working on the webserver with own scripting language; Current progress:
[Script]
string Text = "";
string ImagePath = "C:\CPW\Root\img\Logo.png";
// You always have to seperate the definitions and functions with a line of eachother.
Begin:
{
RenderImage(ImagePath, 4, 1, 12); //Target, Left,Right,Top
RenderText(Text, 4, 1, 12); //Target, Left,Right,Top
//The text will be on top of the image (They go in order).
}
End:
@Viscount S: i understand that you guys wish to keep memory usage low, but you wouldn't even sacrifice a couple of mb's at max (and not even that much if done correctly) of memory for a much better structure? Memory in this situation should not even be considered. For example you saying Millions of Dialog instances can be created, while that is possible if someone decided to spam a million packets to talk to an NPC, and that's even if you have not handled it to even have a delay or check if he's already interacting with an NPC, then yes. But that's not going to happen?
I agree, there are better ways to approach the handling of NPCs, but the memory footprint of each class and its counterparts can play a key role in a server's stability. I will cede that memory usage shouldn't be an issue at the moment (because we all know premature optimization is the root of all evil), and sometimes object creation is more appropriate to create objects to enhance clarity or for simplicity. But it can also be expensive, which is the point I am trying to convey. My point is not memory usage or the garbage collector, but it can effect speed drastically.
I assume you have a background in Java, therefore I'll provide this example from Effective Java by Joshua Bloch:
Item 5: Avoid creating unnecessary objects
Code:
// Hideously slow program! Can you spot the object creation?
public static void main(String[] args) {
Long sum = 0L;
for (long i = 0; i <= Integer.MAX_VALUE; i++) {
sum += i;
}
System.out.println(sum);
}
"Changing the declaration of sum from Long to long reduces the runtime from 43 seconds to 6.8 seconds on my machine."
It is considered good practice to treat your code as if it were a public API, especially now that you have released it. You don't know how that code will be used, anything could happen, even if it's accidental. The code above could be chalked up to a typographical error.
I get fussy about memory issues. Just because the GC handles memory compaction, that means that we should not care about memory and performance.
Also a switch statement isn't a series of if elses, it is more of a goto table:
Is the source ready yet?
We're basicly far enough to launch a beta, we're just fixing up little things.
How long will the beta last?
Till the summer.
What will happen then?
We will switch to native C++ instead.
How long will that take?
We have already done the dataserver and the defender. I'm currently working on the webserver with own scripting language; Current progress:
[Script]
string Text = "";
string ImagePath = "C:\CPW\Root\img\Logo.png";
// You always have to seperate the definitions and functions with a line of eachother.
Begin:
{
RenderImage(ImagePath, 4, 1, 12); //Target, Left,Right,Top
RenderText(Text, 4, 1, 12); //Target, Left,Right,Top
//The text will be on top of the image (They go in order).
}
End:
Only thing left is the source.
Sounds great I really do hope that the server lasts longer than Conquecide did :/ That server ended up shutting down due to lack of interest I believe but anyways like any 1.0 server ran by a good coder i'll be following this forum thread till the server beta is up Hope to see it soon, you guys seem determined and know what your doing so it makes a change, also glad it's going lvling server.
I agree, there are better ways to approach the handling of NPCs, but the memory footprint of each class and its counterparts can play a key role in a server's stability. I will cede that memory usage shouldn't be an issue at the moment (because we all know premature optimization is the root of all evil), and sometimes object creation is more appropriate to create objects to enhance clarity or for simplicity. But it can also be expensive, which is the point I am trying to convey. My point is not memory usage or the garbage collector, but it can effect speed drastically.
I assume you have a background in Java, therefore I'll provide this example from Effective Java by Joshua Bloch:
Item 5: Avoid creating unnecessary objects
Code:
// Hideously slow program! Can you spot the object creation?
public static void main(String[] args) {
Long sum = 0L;
for (long i = 0; i <= Integer.MAX_VALUE; i++) {
sum += i;
}
System.out.println(sum);
}
"Changing the declaration of sum from Long to long reduces the runtime from 43 seconds to 6.8 seconds on my machine."
It is considered good practice to treat your code as if it were a public API, especially now that you have released it. You don't know how that code will be used, anything could happen, even if it's accidental. The code above could be chalked up to a typographical error.
I completely understand where your coming from, since I've proven memory is not an issue ill go on speed. I would not suggest using this if it was going to get called several thousands of times a second, but lets estimate how many of these objects would be created on a server been online for a week. ill estimate 1000 NPC interactions (and yes this is more than people would do) lets say they click 3 options, theres 3k dialog instances created. On my computer running this code
Code:
long curTime = System.currentTimeMillis();
Long sum = 0L;
for (long i = 0; i <= 5000; i++) {
sum += i;
}
System.out.println("Finished: " + (System.currentTimeMillis() - curTime));
Running this code takes 1millisecond, running it using long takes 0 milliseconds. Your not willing to drop a few milliseconds over your entire server time for a better structure?
I also like the amount of knowledge in this topic, don't see much of it on epvp.
I completely understand where your coming from, since I've proven memory is not an issue ill go on speed. I would not suggest using this if it was going to get called several thousands of times a second, but lets estimate how many of these objects would be created on a server been online for a week. ill estimate 1000 NPC interactions (and yes this is more than people would do) lets say they click 3 options, theres 3k dialog instances created. On my computer running this code
Code:
long curTime = System.currentTimeMillis();
Long sum = 0L;
for (long i = 0; i <= 5000; i++) {
sum += i;
}
System.out.println("Finished: " + (System.currentTimeMillis() - curTime));
Running this code takes 1millisecond, running it using long takes 0 milliseconds. Your not willing to drop a few milliseconds over your entire server time for a better structure?
I also like the amount of knowledge in this topic, don't see much of it on epvp.
Just try to keep in mind the fact that each programmer has their own style, and that he likes to do things a certain way, just like you like to do things a certain way, he doesnt have to drop a few milliseconds if he doesnt want to.
You have made your arguement, leave it at that, your starting to sound slightly pushy about it.
Is the source ready yet?
We're basicly far enough to launch a beta, we're just fixing up little things.
How long will the beta last?
Till the summer.
What will happen then?
We will switch to native C++ instead.
How long will that take?
We have already done the dataserver and the defender. I'm currently working on the webserver with own scripting language; Current progress:
[Script]
string Text = "";
string ImagePath = "C:\CPW\Root\img\Logo.png";
// You always have to seperate the definitions and functions with a line of eachother.
Begin:
{
RenderImage(ImagePath, 4, 1, 12); //Target, Left,Right,Top
RenderText(Text, 4, 1, 12); //Target, Left,Right,Top
//The text will be on top of the image (They go in order).
}
End:
Running this code takes 1millisecond, running it using long takes 0 milliseconds. Your not willing to drop a few milliseconds over your entire server time for a better structure?
I also like the amount of knowledge in this topic, don't see much of it on epvp.
This is all nice theory I have to say if you want 100% accuarate information use a Nano Second wrapper. I use a wrapper I found on the internet with some modified code and it works well for accurate timing 1/billionth of a second .
"A nanosecond is equal to 1000 picoseconds or 1/1000 microsecond. Because the next SI unit is 1000 times larger, times of 10-8 and 10-7 seconds are typically expressed as tens or hundreds of nanoseconds." Wiki
Correct. Measuring how long some code takes to execute can be accomplished more precisely so by utilizing , and this method is only there to measure elapsed time in Java. Although, I trust that ChingChong23's results are accurate enough to make his/her point clear. But as Korvacs pointed out, we all have our own style, so perhaps we can agree to disagree.