|
You last visited: Today at 03:07
Advertisement
Sockets
Discussion on Sockets within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.
07/31/2011, 17:57
|
#16
|
elite*gold: 0
Join Date: Jun 2009
Posts: 378
Received Thanks: 141
|
Mr. Pop don't rule out the notion of using unsafe code in c#. It has purpose's. I do agree with you tho. In c# unless you understand it fully keep away from using unsafe code.
|
|
|
07/31/2011, 19:16
|
#17
|
elite*gold: 28
Join Date: Jun 2010
Posts: 2,225
Received Thanks: 868
|
ImFlamedCOD, Long time no see.
Nice to see your face back once and a while. Hi, I'm dreadnought!
|
|
|
08/01/2011, 03:28
|
#18
|
elite*gold: 0
Join Date: Nov 2009
Posts: 754
Received Thanks: 544
|
Quote:
Originally Posted by Mr_PoP
unsafe code it's too messy in c#, and if you are using it because you think you're getting better performance ,in reality, while it might be better, it's not noticeably better, it's a hell of a lot worse to maintain though.
and don't use memcpy on managed memory :P , anyways it's seems OK but try to avoid any unsafe code in you're C# source 
|
You have no idea what you're talking about
|
|
|
08/01/2011, 06:10
|
#19
|
elite*gold: 0
Join Date: Apr 2008
Posts: 759
Received Thanks: 285
|
Quote:
Originally Posted by ImFlamedCOD
Mr. Pop don't rule out the notion of using unsafe code in c#. It has purpose's. I do agree with you tho. In c# unless you understand it fully keep away from using unsafe code.
|
Agreed
Quote:
Originally Posted by ImmuneOne
You have no idea what you're talking about 
|
i really do! but the question why do you use unsafe while you can use the C# built in functions?
like instead of 'memcpy ' use Buffer.BlockCopy ?
|
|
|
08/01/2011, 09:47
|
#20
|
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
|
Quote:
Originally Posted by Mr_PoP
Agreed
i really do! but the question why do you use unsafe while you can use the C# built in functions?
like instead of 'memcpy ' use Buffer.BlockCopy ?
|
Unsafe code is the most efficient way to access/modify data in memory, anyone who denies this is in denial about it.
You just need to run some simple tests, copying 100k objects from 1 array to another using memcpy, and the same test using BlockCopy.
|
|
|
08/01/2011, 17:13
|
#21
|
elite*gold: 0
Join Date: Nov 2009
Posts: 754
Received Thanks: 544
|
Quote:
Originally Posted by Mr_PoP
Agreed
i really do! but the question why do you use unsafe while you can use the C# built in functions?
like instead of 'memcpy ' use Buffer.BlockCopy ?
|
You run the tests, compare them and then tell me why you should use memcy or Buffer.Blockcopy instead.
|
|
|
08/01/2011, 21:14
|
#22
|
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 756
|
Quote:
Originally Posted by ImmuneOne
You run the tests, compare them and then tell me why you should use memcy or Buffer.Blockcopy instead.
|
memcpy is native, which makes the performance better as it's probably c or c++. Right?
|
|
|
08/01/2011, 22:06
|
#23
|
elite*gold: 0
Join Date: Feb 2009
Posts: 262
Received Thanks: 161
|
or use..
Code:
void MEMCPY(byte[] Received, byte[] Buffer, int Len)
{
// fixed (byte* pointer = Received, buffer = Buffer)
// MSVCRT.MEMCPY(pointer, buffer, Len);
byte[] Received = new byte[Len];
for (int x = 0; x < Len; x++)
{
Received[x] = Buffer[x];
}
}
|
|
|
08/02/2011, 00:02
|
#24
|
elite*gold: 0
Join Date: Jan 2008
Posts: 1,443
Received Thanks: 1,175
|
Managed vs Unmanaged in C#... I know these things, but it will give a better idea of the reality and you'll see that the difference is so little that you can use what you want...
Tested on Windows XP x64, for a copy of 50'000'000 elements and tested 1000 times for precision. All values in ms.
| Target | Buffer.BlockCopy | Array.Copy | memcpy (void*) | memcpy (IntPtr) | memcpy (void*, fixed byte*) | memcpy (fixed byte*, fixed byte*) | | x64 | 31.547 | 30.734 | 30.201 | 30.922 | 34.817 | 29.760 | | x86 | 43.606 | 41.208 | 37.309 | 37.626 | 40.051 | 37.704 | | Any | 28.422 | 27.097 | 25.858 | 26.542 | 30.531 | 26.087 |
Results:
Allocating managed resources takes more times than unmanaged resources.
Byte[] = new Byte[], Byte* = (Byte*)Marshal.AllocHGlobal()
x64 is fastest than x86 on 64 bits OS.
Any CPU is fastest than x64 on 64 bits OS and probably on 32 bits OS (x86).
Array.Copy is fastest than Buffer.BlockCopy.
There is no difference between void* and IntPtr.
There is no difference between fixed pointer and pointer.
Native function memcpy is fastest than Array.Copy.
|
|
|
08/06/2011, 23:24
|
#25
|
elite*gold: 0
Join Date: Jun 2008
Posts: 113
Received Thanks: 19
|
I don't see a need to change what anyone is comfortable with because it would be fractions of a nanosecond faster
Hopefully I'm not the only one that sees it that way
Nice release bauss..might save it for later
|
|
|
08/07/2011, 00:53
|
#26
|
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 756
|
Quote:
Originally Posted by GRASSHOPPA
I don't see a need to change what anyone is comfortable with because it would be fractions of a nanosecond faster
Hopefully I'm not the only one that sees it that way
Nice release bauss..might save it for later
|
I changed some few things, if you want to see what, feel free to check out my source ^^
Working on some extremely sockets atm.
|
|
|
08/08/2011, 13:44
|
#27
|
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
|
Quote:
Originally Posted by GRASSHOPPA
I don't see a need to change what anyone is comfortable with because it would be fractions of a nanosecond faster
Hopefully I'm not the only one that sees it that way
Nice release bauss..might save it for later
|
Sadly its not fractions of a nanosecond faster, its several milliseconds faster, and when writing a server several milliseconds is a long time.
|
|
|
08/09/2011, 00:33
|
#28
|
elite*gold: 0
Join Date: Jun 2008
Posts: 113
Received Thanks: 19
|
Quote:
|
Originally Posted by CptSky
Tested on Windows XP x64, for a copy of 50'000'000 elements and tested 1000 times for precision. All values in ms.
|
Correct me if I'm wrong but isn't he saying each function was called 50 million times?
I try to keep things as efficient as possible(I of course don't know as much as a majority of the people reading this)..but I don't see anything I'd design that calls anything hundreds of millions of times
|
|
|
08/09/2011, 00:37
|
#29
|
elite*gold: 28
Join Date: Jun 2010
Posts: 2,225
Received Thanks: 868
|
lolz.
He means an array with 50million **** in
Easy to make
Code:
ulong[] x = new ulong[50000000];
for (ulong i = 0; i < 50000000; i++)
{
x[i] = i*3/4;
}
then just copying the array to another array and seeing how long it takes.
What he meant was each function was called One Thousand times.
^^All for testing.
|
|
|
08/09/2011, 01:17
|
#30
|
elite*gold: 0
Join Date: Jun 2008
Posts: 113
Received Thanks: 19
|
ohhhh...that makes a bit more sense lol
Either way ill stick to Array.copy
|
|
|
 |
|
Similar Threads
|
Sockets first to log in after SM
03/14/2007 - Conquer Online 2 - 13 Replies
If i was the first to log in after SM will the 1st met be the socket? or is there a certian amount i would have to spam? Thanks :) cheers i have quit this game for a while but I am back now. :P
|
Sockets in CO?
03/16/2006 - Conquer Online 2 - 14 Replies
I was reading through the socket thread on the other forum and such... I know a few people who are 100 pct on making 1 socket and around 90 pct on the 2nd socket... So I am wondering if there is a way to make it happen without a chance of failure? I know that the Conquer Online Beta Client (the old old one) you can make sockets without worry on anything with that client... Does anyone know where to get it or know someone who'd upload it to a server? Or just knows a fool proof way to...
|
Sockets
03/01/2006 - Conquer Online 2 - 35 Replies
Hi there everyone, just like to post what i know about socket making in TC.
I don't post much unless I know what i am talking about. OK I tried pretty much every theory that there is arround about making a socket, I spammed 400 mets, I followed the xx:33 theory for over a month and had no success. But then out of know where I get 2 sockets in one week and another 1 this week by following a simple procedure, ok here it is:
1. Get 20 mets (If 20 mets can't get a socket, I don't think...
|
HELP WITH SOCKETS!
07/06/2005 - Conquer Online 2 - 6 Replies
Hi again, i was thinking about quiting the game but i dicided to try to make sockets in every thing so i sold all my equip(made 60mil) bought low lvl supers/unique/elite and dbs.IM a trojan :D. my boots,necky and attack ring was unique LOW lvl and i gave it all dbs to get super and trojan armor lvl 15 was elite and i made it super and i bought a low lvl super cornet. Today i gave my ring 65 mets and ring reach lvl 80 by doing so no socket :cry: . .any one no the best way i and get sockets.PLZ...
|
All times are GMT +1. The time now is 03:07.
|
|