Weird processing speed

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.

+3
source share
2 answers

If a person can walk 2 miles in 30 minutes, how long will it take 2 people to go the same 2 miles?

, MSDN : for (For in Visual Basic), MAY . .

CLR , , .net CLR , .

( ) - 21,495 , : 7,03 . i7 870 32- Windows 7.

+1

Parallel.For .

sqrt(i) , sqrt(smallernumbers) sqrt(largernumbers).

- , , - , , .

, , , , , . preempted , , , , .

0

All Articles