نقل قول نوشته شده توسط hossein-khoshseyar مشاهده تاپیک
دوستان این کد سی



double[] n1 = new double[11000];
double[] n2 = new double[11000];
double[] y = new double[11000];
long cun1 = 0;
long cun2 = 0;
long freq = 0;
bool d;
//[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("kernel32")]
private static extern bool QueryPerformanceFrequency(ref long PerformanceFrequency);
//[System.Security.SuppressUnmanagedCodeSecurity] // We won't use this maliciously
[DllImport("kernel32")]


private void button1_Click(object sender, EventArgs e)
{


d= QueryPerformanceCounter(ref cun1);

for (int m = 1; m < 100000; m++)
for (int n = 0; n < 10000; n++)
{
n1[n] = n;
n2[n] = n;
y[n] = n1[n] * n2[n];
}
QueryPerformanceCounter(ref cun2);
QueryPerformanceFrequency(ref freq);
label1.Text = ((float)(cun2 - cun1) / freq).ToString();

}
اینم کد وی بی


Dim n1(11000), m1(11000), j(11000) As Double
Dim c1, c2, frq As Double
Dim n, m As Int32
Declare Function QueryPerformanceCounter Lib "kernel32.dll" (ByRef x As Int64) As Byte
Declare Function QueryPerformanceFrequency Lib "kernel32.dll" (ByRef x As Int64) As Byte
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click




QueryPerformanceCounter(c1)
For m = 1 To 100000
For n = 0 To 10000

n1(n) = n
m1(n) = n
j(n) = n1(n) * m1(n)
Next
Next



QueryPerformanceCounter(c2)
QueryPerformanceFrequency(frq)
Label1.Text = (c2 - c1) / frq
End Sub
فقط احتمال داره که تو نمونه ای که فایل اجراییش رو براتون گذاشته بودم تعدداد اجرای حلقه for با این یه کم متفاوت باشه


تاپیک این همه رفته جلو ولی هنوز کسی نگفته این دو تا کد معادل هم نیستن ؟

For m = 1 To 100000
For n = 0 To 10000



for (int m = 1; m < 100000; m++)
for (int n = 0; n < 10000; n++)


تعداد تکرار حلقه ها به طرز فجیعی با هم اختلاف دارن ! اگه سرعت ایندو برابر بود بیشتر جای تعجب داشت .