Closed rouvian closed 1 year ago
Hi @rouvian,
We've reproduced the performance regression and will address it in the next release.
By the way, the JavaScript syntax obj(arg)
is rarely used for invoking managed indexers, but it requires fewer host calls than the more common obj.Item(arg)
or obj.Item.get(arg)
, so it's faster.
However, you could still do better by doing the indexing in managed code:
engine.Script.getRow = new Func<DataRowCollection, int, DataRow>((drs, i) => drs[i]);
engine.Script.getCol = new Func<DataRow, int, object>((dr, i) => dr[i]);
And then, in JavaScript:
const drs = dt.Rows;
const count = drs.Count;
for (let i = 0; i < count; ++i) {
const dr = getRow(drs, i);
const value = getCol(dr, 0);
// ...
}
The performance regression you discovered doesn't affect this technique, so it should yield a significant boost in all recent ClearScript versions.
Thanks for reporting this issue!
Version 7.3.5 addressed the performance regression.
Here is a sample script which accesses a DataRow
The line value = dr(0) cause OperationCanceledException which is caught internally. However, this causes a big performance issue in the loop. The issue is in TypeHelpers.cs in the source code of ClearScript:
The same issue does not occur in 7.3.1.