VB and VC ++ competition

zhaozj2021-02-16  45

Author: jyu1221 (same day)

QQ: 19632995msn: jyu1108@hotmail.com

Many people see this title, and must only think that VC is better than VB performance. But you read this test example below, you will have a 180 degree shift for this view, don't believe it, you can look at the test data below. On the dialog box of VB and VC , put a listbox box, then put a button, add 50,000 records in the Button's Click event, and the record content is "abcdef", where the TimegetTime function is used to record Time, VB is called API, need to be defined.

The code in VB is as follows: private sub button1_click () DIM L1 As long, l2 as long l1 = timegettime () for i = 1 to 50000 list1.additem "Abcdef" Next L2 L2 = TimegetTime () MSGBOX L2 - L1END SUB

The code in the VC is as follows: void ctestdlg :: OnButton1 () {clistbox * p; p = (clistbox *) getdlgitem (idc_list1); long l1 = timegettime (); for (int i = 0; i <50000; i )) {P-> addstring ("abcDef");} long l2 = timegettime (); cstring str1; str1.format ("% d", l2-l1); :: MessageBox (null, str1, str1, 0);} The above code is the most common, the general people write code is this, no optimization, on my machine (Win2000, P3) test, test results:

转载请注明原文地址:https://www.9cbs.com/read-26764.html

New Post(0)