time it takes for VB to count to 1000000000 : 19.203 seconds
VB Code:
Option Explicit Private Declare Function GetTickCount Lib "kernel32" () As Long Dim firstnumber As Double Dim secondnumber As Double Dim thirdnumber As Double Private Sub Form_Load() secondnumber = 0 firstnumber = GetTickCount() While secondnumber <= 1000000000# secondnumber = secondnumber + 1 Wend thirdnumber = GetTickCount() MsgBox "time taken to count to 1000000000: " & thirdnumber - firstnumber End Sub
C++ Code:
#include "stdafx.h"
#include "iostream.h"
#include "windows.h"
// how long does it take the computer to increment a var 100000 times?
void main()
{
double firstnumber;
double secondnumber=0;
double thirdnumber;
firstnumber = GetTickCount();
while (secondnumber <= 1000000000)
{
secondnumber++;
}
thirdnumber = GetTickCount();
cout << "time taken: " << thirdnumber - firstnumber;
}
No comments:
Post a Comment