Tested several C # scripting engines, Jint, Jurassic, Nlua, Clearscript

Source: Internet
Author: User
Tags vc runtime

Test class

    public class Script_common {public string read (string filename) {return SYSTEM.IO.FILE.R        Eadalltext (filename); The public void log (object obj) {Console.WriteLine (obj).        GetType () + "-" + obj); The public void demo (params object[] items) {log (string.        Join ("-", items));        } public void Demo2 (String def = "ddddddddddd") {log (Def);        } public void Demo3 (string val) {log (val);        } public void Demo3 (int val) {log (val);        The public Regex regex (string pattern) {return new Regex (pattern); Public match Match (string input, string pattern) {return System.Text.RegularExpressions.Regex .        Match (input, pattern);          } System.Diagnostics.Stopwatch Stopwatch = new System.Diagnostics.Stopwatch (); public void time1 () {LoG ("timing begins:"); Stopwatch.        Restart (); } public void Time2 () {stopwatch.            Stop (); Log ("Time to end:" + stopwatch.        Elapsedmilliseconds + "milliseconds"); }    }

Test scripts

T.time1 ();                              Timing Start htm = t.read (' D:/nn2log.txt ') for (var i = 0; i < 10000; i++) {    var r = new RegExp (' [a-z]+ ');    HTM + = r.exec (htm). length}t.time2 ();                              Chronograph end T.log (htm.length) T.demo (11,22,33,44,55)       //test support params
T.demo2 () //test supports default parameter T.demo2 (' DDDDDDDDDDDDD ')

T.DEMO3 (111) ///test whether to support multiple methods This is very important, JS call C # method, many methods of C # are multi-method definition: If not supported, success may not be called.
T.demo3 (' dddddddd ')

 

Script test Results

Jint supports params, does not support default parameters, does not support multiple methods,

Jurassic supports params, does not support default parameters, supports multiple methods,

The Nlua supports params, supports default parameters, supports multiple methods,

The clearscript supports params, supports default parameters, supports multiple methods,

Clearscript is tested using the "Jscriptengine" method, and without using the V8 engine, mono seems to be unable to use it, and there is no test.

In terms of performance, it's probably

Nlua or Jurassic > Clearscript or Jint

It's probably just a matter of testing a few string operations and regular expression loops, and testing is not exhaustive.

Clearscript in the use of JS RegExp time performance is the best, but added a C # var rr = T.regex (' [a-z]+ ') after the performance is very bad, do not know why.

project maintenance aspects.

Nlua or Clearscript or Jint > Jurassic

Nlua or Clearscript or Jint these 3 have been in the maintenance of the update

Jurassic has not been updated for 2 years, but after testing the feeling is very good, compatibility +, performance is also OK,

Compatibility Aspects

Nlua or Jint or Jurassic > Clearscript

Nlua needs to call 2-3 DLLs, multi-platform support: Ios,linux, Windows

Jint Jurassic is a DLL, written in pure C #, compatibility should be OK, Linux has not been tested, but read Mono's documentation, should be supported.

Clearscript use JScript mode only one DLL is enough, but it seems that the system interface is called, cross-platform does not know how, V8 mode needs to call 2-5 DLLs, and V8 engine is written in VS2013. Also need to install VC runtime ... Feel the engine or C # to write better, abnormal capture ah those are more convenient.

http://www.okbt.net/Magnetic search engine, developed using C # + Python. aspx runs on Linux.

Tested several C # scripting engines, Jint, Jurassic, Nlua, Clearscript

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.