VBScript with JScript who is afraid who (5)

Source: Internet
Author: User
Tags array execution expression iis regular expression
Turn from: chinabyte


The results of the first set of tests are shown in the following table. The values in the table are the average execution times of 1000 ASP page calls under different scenarios, in seconds (the test routine executes once per ASP page execution). Scheme
Language * * * string Flip * String Lookup * * Regular expression pattern matching * Displacement operation * Simple mathematical calculation * Complex mathematical calculation * *
Vb-vb 2.245 2.038 4.452 2.200 2.173 2.151
Js-js 2.690 2.214 2.635 2.166 2.288 2.313
Vb-js 3.522-3.430 3.035-3.178
JS-VB 3.185-5.368 3.103-3.004
* Run 96 times, of which: 24 times is VBScript Test Tool page, IIS default scripting language vbscript;24 is the JScript Test Tools page, the IIS default scripting language vbscript;24 is the VBScript Test Tool page, IIS default scripting language JScript, and 24 more are JScript test tools pages, IIS default scripting language JScript. To reduce the effect of the order, the order in which the 第一、三、四、六 test routines are run changes each time. The time shown in the table above is the average time of 96 runs. All detail data can be found in the download package's Data.xls file.

* * Run 24 times with the VBScript test Tools page, the IIS scripting language is set to VBScript (no combination of other test tool pages and default scripting languages is running because they do not show any order or time variance in the initial run).

VB represents VBSCRIPT,JS on behalf of JScript. The first of the two languages is the basic language of the page, and the second is the language in which the code is embedded. Inline code is not used in situations where it is not needed.



Most of the test results are very obvious, but you should pay attention to two possible surprising results. We know that JScript handles regular expressions through the method of string objects with greater flexibility, while VBScript needs to instantiate the cost of RegExp objects. Surprisingly, code written entirely in VBScript is slower than code that completes pattern-matching operations with inline JScript functions, in VBScript as the base language. Obviously, instantiating a RegExp object in VBScript requires a considerable amount of time overhead.

The second surprise is that although JScript's bit operations are always shown to be faster than VBSCIRPT, the time difference between the two is very small in these tests.

The results of the second set of tests are shown in the following table. The values in the table represent the average execution time of a single ASP page under different scenarios, measured in seconds (every time an ASP page is executed, the test routine runs multiple times). Scheme
Language * * String Flip (1) string search (3) Regular expression pattern matching (2) displacement operation (3) Simple mathematical calculation (1) complex mathematical calculation (3) array initialization (1) recordset traversal (4)
VB-VB 0.120 0.346 2.250 0.200 0.287 0.328 2.182 0.524
Js-js 2.589 0.998 0.138 0.036 0.426 0.499 9.120 0.641
Vb-js 3.066-0.221 0.890-1.310--
JS-VB 0.472-2.363 0.769-0.671--
* Each scenario is run 24 times with the VBScript test Tools page, and the default scripting language for IIS is VBScript (there are no other test tool pages running and the IIS default scripting language combination because they do not show any order or time variance in the initial run). To reduce the effect of the order, the order in which the 第一、三、四、六 test routines are run changes each time. The above table shows the average time of 24 runs and all the details can be found within the Data.xls of the download package.

**VB represents VBSCRIPT,JS on behalf of JScript. The first of the two languages is the basic language of the page, and the second is the language in which the code is embedded. Inline code is not used in situations where it is not needed.

100,000 iterations
1,000 iterations
10,000 iterations
External loops for 830 records, internal loops for 14 fields (11,620 iterations in total)



The results of these tests clearly confirm the difference between the two languages. As can be seen from the mathematical calculations, VBScript is faster than JScript in this area-except for the displacement operation (JScript itself supports displacement operations, which VBScript does not support).

The most significant differences between the two languages are string flip, string search, and array initialization, all of which are in the ascendant for VBScript.

The string rollover operation is supported by VBScript itself, and in this test the difference is particularly pronounced. In this test, the difference between the two makes it much quicker to use the inline VBScript StrReverse () function than to write the function in JScript.

Database recordset traversal is a fairly common operation in applications where data churn is so frequent that it makes manual construction of data meaningless. The difference between VBScript and JScript on recordset traversal in the above test results may give some warning to those who think JScript is superior to VBScript. However, this difference in execution time can also be justified by the fact that we have instantiated a enumerator object for each record in the recordset (830 times altogether!). )。

As you can see from the results of the first set of tests, regular expression pattern matching is a place where JScript is definitely better than VBScript, so the test results for this group are not surprising. The test results here confirm the results of the previous group, but the degree of difference is magnified.



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.