Hi,
multi-threading is only a logically instruction-level parallelism under single processor environment, while multiple processor provides the ability of physically instruction-level parallelism. beyond all question, multi-threading application will gain lots of performance improvement under multi-processor environment.
currently, we cannot determine that "which thread runs on which processor" in a .net application, mostly, it is the OS who in charge of thread scheduling for you (get more from this book "Operating Systems: Internals and Design Principles").
so, it is no need to take care about how many processor there are, just launch some time-consuming threads in your application, and let the application run in different machines to see their difference. following code snippet may give some help to you:
static void Main(string[] args)
{
try
{
Console.WriteLine("Inputs threads count and press enter, 'end' for exit.");
string count;
while (!(count = Console.ReadLine().Trim()).Equals("end"))
{
int result = 0;
if (int.TryParse(count, out result))
{
DateTime begin = DateTime.Now;
for (int i = 0; i < result; i++)
{
Thread t1 = new Thread(new ThreadStart(M1));
t1.Start();
t1.Join();
}
DateTime end = DateTime.Now;
Console.WriteLine("Total ticks: " + (end - begin).Ticks.ToString());
}
else
{
Console.WriteLine("Invalide number.");
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
Console.WriteLine("Main done.");
Console.ReadLine();
}
public static void M1()
{
for (int i = 1; i < 1000000000; i++)
{
Math.Cos(1/i);
}
}
Thanks,
Eric
Please remember to mark helpful replies as answers and unmark them if they provide no help.