나는 약간 혼란스러운이 간단한 질문을 얻었다. 저는 2 개의 프로세서를 가지고 있습니다 33.0360723에서 각각 10 억 개의 작업을 개별적으로 수행 할 수 있습니다. 그러나 둘 다 함께 27.4996964의 작업을 수행합니다.이상하게 작동하는 처리 속도
하나의 프로세서에 대한 작업 시간이 X라면 둘 다 함께 X/2가되지 않아야합니까?
내 코드 :
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 : 나는 VB.net이에 대한 코드를했다.
코드를 보여주세요! 대부분의 경우에는 실제 작업보다 두 프로세서의 동기화에 훨씬 많은 오버 헤드가 있습니다. – Aron
두 번째 프로세서가 하이퍼 스레딩 가상 프로세서입니까? –
이것은 좋은 질문이므로 닫아서는 안됩니다. – xpda