I had a simple question that confused me a bit. I have 2 processors. Both of them can individually carry out 1 billion operations in 33.0360723. However, both of them perform operations together at 27.4996964.
It makes no sense to me if the time for a task for one processor is equal to X, then shouldn't that be X / 2 for both of them?
My code is:
Function calc(ByVal i As Integer, ByVal result As String)
Math.Sqrt(i)
Return True
End Function
Sub Main()
Dim result As String = Nothing
Dim starttime As TimeSpan
starttime = DateTime.Now.TimeOfDay
For i = 0 To 1000000000
calc(i, result)
Next
Console.WriteLine("A single processor runs 1 billion operations in: ")
Console.WriteLine(DateTime.Now.TimeOfDay - starttime)
starttime = DateTime.Now.TimeOfDay
Parallel.For(0, 1000000000, Function(i) calc(i, result))
Console.WriteLine("All your processors run 1 billion operations in: ")
Console.WriteLine(DateTime.Now.TimeOfDay - starttime)
Console.ReadLine()
End Sub
PS: I made a code for this in VB.net.
user3151371
source
share