J
jimocz
Did I do something wrong? I cross posted this on the dotnet
development group -- sorry if it is a double posting but we are
seriously considering going to c# and this could be a show stopper.
I ran the following C# program and it ran in 9 seconds (give or take 1
sec)
using System;
using System.Collections.Generic;
using System.Text;
namespace DotProduct1Million
{
class Program
{
static void Main(string[] args)
{
double d1 = 0.727272;
double d2 = 0.26252;
double d3 = 343432.232;
Console.WriteLine(" {0}", System.DateTime.Now);
for (long i = 0; i < 2000000000; i++)
{
d3 = d1 * d2;
d1 = d3 * d2;
d2 = d2 * d2;
d3 = d1 * d2;
d3 = d3 * d2;
}
Console.WriteLine(" {0}", System.DateTime.Now);
}
}
}
I ran the following C++ program -- it ran in under 1 second. Is C#
really that much slower than C++????
What is the problem here?
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main(int argc,char *argv[])
{
double d1 = 0.727272;
double d2 = 0.26252;
double d3 = 343432.232;
cout << time(NULL) << endl;
for (long i = 0; i < 2000000000; i++)
{
d3 = d1 * d2;
d1 = d3 * d2;
d2 = d2 * d2;
d3 = d1 * d2;
d3 = d3 * d2;
}
cout << time(NULL) << endl;
development group -- sorry if it is a double posting but we are
seriously considering going to c# and this could be a show stopper.
I ran the following C# program and it ran in 9 seconds (give or take 1
sec)
using System;
using System.Collections.Generic;
using System.Text;
namespace DotProduct1Million
{
class Program
{
static void Main(string[] args)
{
double d1 = 0.727272;
double d2 = 0.26252;
double d3 = 343432.232;
Console.WriteLine(" {0}", System.DateTime.Now);
for (long i = 0; i < 2000000000; i++)
{
d3 = d1 * d2;
d1 = d3 * d2;
d2 = d2 * d2;
d3 = d1 * d2;
d3 = d3 * d2;
}
Console.WriteLine(" {0}", System.DateTime.Now);
}
}
}
I ran the following C++ program -- it ran in under 1 second. Is C#
really that much slower than C++????
What is the problem here?
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main(int argc,char *argv[])
{
double d1 = 0.727272;
double d2 = 0.26252;
double d3 = 343432.232;
cout << time(NULL) << endl;
for (long i = 0; i < 2000000000; i++)
{
d3 = d1 * d2;
d1 = d3 * d2;
d2 = d2 * d2;
d3 = d1 * d2;
d3 = d3 * d2;
}
cout << time(NULL) << endl;