Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

ScriptPack - version 2017 - Speed calling a script


I would like to use the script pack as an external editor of functions.

However, when Delphi calls a script a Million times like in this example below the overhead time makes it impossible to use it in a real case scenario. It takes forever...

Each call to run the script takes approximately 0.00034 seconds

How can this be solved? Thanks

  LMDScriptControl1.Active := False;


  LMDScriptControl1.Source.Text := Memo1.Text;

  edInputNumber.Text :=inttostr(5);

  for k:=1 to 1000000 do begin

    LMDScriptControl1.AddOrSetValue( 'edInputNumber', TEdit_sw.ToVar(edInputNumber));
    LMDScriptControl1.AddOrSetValue('lbResult', TLabel_sw.ToVar(lbResult));

    LMDScriptControl1.Active      := True;
     LMDScriptControl1.Active := False;


  • 7 Comments sorted by Votes Date Added
  • Try write your code in script procedure and use RunProc instead of re-activating script engine on each call. However, script will not be super fast anyway. Its a script.
  • Thank you. I measure in general a slow down from native code of about 100 times..depending on the script code you are running.A faster solution would really be welcome...

  • Strange requirement. Scrips are always much slower than native code.
  • In situations where the script code needs to be executed millions of times it may be important. If you write a script procedure that will calculate a some output for objects in a given model, and it happens that those objects can exist in the range of tenths of millions, it is clear that speed will become important. Imagine code that would execute in 1 minute in native code, but in script will become almost 2 hours..makes a big difference...
  • The only conclusion -  do not use scripts in such situation.
  • Well, with a requirement to have that code available to the user, there are not much other options . Or scripting or VSTA...However I have no idea how to integrate VSTA fin a Delphi application...
  • Speed optimization is a non trivial aspect. It mostly should be solved algorithmically, by excluding from script code speed critical pieces. There several potential ways, for example, to implement speed critical pieces in native code and allow to call them from script, implement API based on arrays, which will batch speed critical operations, ect.
    Anyway, this is out of scope of our support forum and LMD ScriptPack product.
Sign In or Register to comment.