IpParse DnsGetHost Entry
using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace Server
{
class Program
{
static void Main(string[] args)
{
Console.SetWindowSize(40, 20);
List<long> time1 = new List<long>();
List<long> time2 = new List<long>();
System.Diagnostics.Stopwatch st1 = new System.Diagnostics.Stopwatch();
System.Diagnostics.Stopwatch st2 = new System.Diagnostics.Stopwatch();
for (int i = 0; i < 100; ++i)
{
st1.Start();
IPEndPoint ep = new IPEndPoint(IPAddress.Parse("192.168.212.21"), 48888);
st1.Stop();
time1.Add(st1.ElapsedMilliseconds);
}
for (int i = 0; i < 100; ++i)
{
st2.Start();
IPEndPoint serverEndpoint = new IPEndPoint(Dns.GetHostEntry("192.168.212.21").AddressList[0], 48888);
st2.Stop();
time2.Add(st2.ElapsedMilliseconds);
}
long avg = 0;
StringBuilder sb = new StringBuilder();
foreach (long l in time1)
{
sb.Append(l.ToString() + ", ");
avg += l;
}
Console.WriteLine(@"IP-Address Parse Average: {0}", avg / time1.Count);
Console.WriteLine(sb.ToString());
avg = 0;
sb = new StringBuilder();
foreach (long l in time2)
{
sb.Append(l.ToString() + ", ");
avg += l;
}
Console.WriteLine(@"DNS GetHostEntry Average: {0}", avg / time2.Count);
Console.WriteLine(sb.ToString());
Console.ReadLine();
}
}
}
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace Server
{
class Program
{
static void Main(string[] args)
{
Console.SetWindowSize(40, 20);
List<long> time1 = new List<long>();
List<long> time2 = new List<long>();
System.Diagnostics.Stopwatch st1 = new System.Diagnostics.Stopwatch();
System.Diagnostics.Stopwatch st2 = new System.Diagnostics.Stopwatch();
for (int i = 0; i < 100; ++i)
{
st1.Start();
IPEndPoint ep = new IPEndPoint(IPAddress.Parse("192.168.212.21"), 48888);
st1.Stop();
time1.Add(st1.ElapsedMilliseconds);
}
for (int i = 0; i < 100; ++i)
{
st2.Start();
IPEndPoint serverEndpoint = new IPEndPoint(Dns.GetHostEntry("192.168.212.21").AddressList[0], 48888);
st2.Stop();
time2.Add(st2.ElapsedMilliseconds);
}
long avg = 0;
StringBuilder sb = new StringBuilder();
foreach (long l in time1)
{
sb.Append(l.ToString() + ", ");
avg += l;
}
Console.WriteLine(@"IP-Address Parse Average: {0}", avg / time1.Count);
Console.WriteLine(sb.ToString());
avg = 0;
sb = new StringBuilder();
foreach (long l in time2)
{
sb.Append(l.ToString() + ", ");
avg += l;
}
Console.WriteLine(@"DNS GetHostEntry Average: {0}", avg / time2.Count);
Console.WriteLine(sb.ToString());
Console.ReadLine();
}
}
}