Is vc++.net really useless?

Source: Internet
Author: User

is C + + really no use?
Vb.net,c# is the focus of the Microsoft. NET Framework. is C + + really no use?
is C + + really a real one?

The following C + + refers to managed C + +, if the use of Win32 C + + and. NET ratio is meaningless, there is no technical content.

Here's a test:

static void Function1 ()
{
int i = 0, j = 0, a = 0;

for (i = 0; i < 100000; i++)
j = i;
}
static void Function2 ()
{
int i = 0, j = 0;

            for (i = 0; i < 200000 i++)
  & nbsp;             j = i;
       }
        static void Main (string[] args)
         {
            int i = 0, j = 0;
            for (i = 0; i < i++)
   & nbsp;            function1 ();
            for (i = 0; i < 50000 i++)
  & nbsp;             function2 ();


}
Such code allows C # to run for 7 seconds, note: vc++.net code similar, do not list.
If you don't get C + + running for 2 seconds.
Intensified, all I < 200000;
The for (i = 0; i < 200000 i++) does not affect C + + in the slightest.

Test 2:
Sorting algorithm:

C++

Namespace Cdll {

Public ref class Class1
{
Public:void sort (array<int> ^list)
{
int i,j;
int temp;
BOOL Done=false;
J=1;
while ((j<list->length) && (!done))
{
Done=true;
for (i=0;i<list->length-j;i++)
{
if (list[i]> (list[i+1]))
{
Done=false;
Temp =list[i];
LIST[I]=LIST[I+1];
List[i+1]=temp;
}
}
j + +;

};
}
};
}

C#

Using System;
Using System.Collections.Generic;
Using System.Text;

Namespace ClassLibrary1
{

public class Bubblesorter
{
public void sort (int[] list)
{
int I, j, temp;
bool done = false;
j = 1;
while (J < list. Length) && (!done))
{
Done = true;
for (i = 0; i < list. Length-j; i++)
{
if (List[i] > list[i + 1])
{
Done = false;
temp = List[i];
List[i] = list[i + 1];
List[i + 1] = temp;
}
}
j + +;
}
}
}
}

Test Console:

static void Main (string[] args)
{
Random ran=new Random ();
Int[] Iarrary=new int[80000];

System.Text.StringBuilder s=new StringBuilder ();
int temp;
for (int i = 0; i < 80000; i++)
{Iarrary[i] = ran. Next (100000);
temp = Iarrary[i];

S.append ("");
S.append (Iarrary[i]. ToString ());
}
Classlibrary1.bubblesorter csb=new Classlibrary1.bubblesorter ();
Cdll. Class1 CPB = new Cdll. Class1 ();

System.IO.File.AppendAllText (@ "C:/1.text", s.tostring ());

Console.WriteLine (DateTime.Now);
Csb.sort (iarrary); Test C #

Cpb.sort (iarrary); C + +
Console.WriteLine (DateTime.Now);
for (int i = 0; i < 80000; i++)
{

S.append ("");
S.append (Iarrary[i]. ToString ());
}
System.IO.File.AppendAllText (@ "C:/2.text", s.tostring ());
Console.read ();
}
Output:
C#
2007-10-13 12:22:13
2007-10-13 12:22:36
C++
2007-10-13 12:23:21
2007-10-13 12:23:45

You can see C + + and C #不分伯仲 in bubble sort (bubble).
(Note I tested different language. DLL calls for more than 1 s)

Tools: VC + + 2005 computer CPU Pentium D820, memory DDR2 667 1G, System: windows2003 (SP2), Vista final version

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.