Hi!
at the moment i'm using the trial license to do some tests with AlterNET.Scripter.
I want to use it in my Project to execute the business logic with c# scripts.
do you have real world experience with many, many scripts loaded at runtime?
normally the business logic of a big ERP application has around 3000-4000 methods. i would like to have every method in a single script.
so if i have 4000 methods, it would load 4000 DLLs on startup...
regards,
ferdinand
Hi,
It may not necessary to create a separate ScriptRun/DLL for each of your scripts. You could have them all in a single DLL, but in different code files. For example, each one could contain a method of a single C# partial static class. Then you could choose which one to run via ScriptRun.RunMethod(). This way you would need to have only a single script DLL loaded.
It may not necessary to create a separate ScriptRun/DLL for each of your scripts. You could have them all in a single DLL, but in different code files. For example, each one could contain a method of a single C# partial static class. Then you could choose which one to run via ScriptRun.RunMethod(). This way you would need to have only a single script DLL loaded.
In addition to my reply above:
This is of course not a real world scenario, however we've created a test that shows how long it takes to compile 4000 scripts.
We used the following code:
void CreateAndRunScript()
{
var scriptRun = new ScriptRun();
scriptRun.ScriptSource.FromExpression("System.Math.Min(1, 3).ToString() + "hello".Length");
if (!scriptRun.Compile())
throw new Exception();
scriptRun.Run();
}
const int Count = 4000;
var sw = new Stopwatch();
sw.Start();
for (int i = 0; i < Count; i++)
{
CreateAndRunScript();
}
sw.Stop();
MessageBox.Show(sw.Elapsed.ToString());
This code takes 1 minute and 18 seconds to execute on my machine.
This is of course not a real world scenario, however we've created a test that shows how long it takes to compile 4000 scripts.
We used the following code:
void CreateAndRunScript()
{
var scriptRun = new ScriptRun();
scriptRun.ScriptSource.FromExpression("System.Math.Min(1, 3).ToString() + "hello".Length");
if (!scriptRun.Compile())
throw new Exception();
scriptRun.Run();
}
const int Count = 4000;
var sw = new Stopwatch();
sw.Start();
for (int i = 0; i < Count; i++)
{
CreateAndRunScript();
}
sw.Stop();
MessageBox.Show(sw.Elapsed.ToString());
This code takes 1 minute and 18 seconds to execute on my machine.