I’m trying to use the performance.now()
method, but using Delphi in TMS WEB Core.
In JavaScript I can do this:
const t0 = window.performance.now();
for (let i = 0; i < 100000; i++) {
// some code
}
const t1 = window.performance.now();
console.log(`For Loop took ${t1 - t0} milliseconds.`);
I can see that in the Delphi IDE code completion, there is a window.performance
which is of type TJSPerformance
:
But I’m not sure how to use it and I can’t find any documentation on it. If I ctrl+left-click into TJSPerformance
, it’s defined in the Web
unit, but it’s empty:
TJSPerformance = class(TJSObject)
end;
But I’ve seen many things that appear empty when I ctrl+left-click, but then they still work and actually have things in it somewhere.
I’m not able to do window.Performance.now()
in Delphi as that results in an error that says:
[Error] uIndex.pas(197): identifier not found “now”
I basically want to use this to calculate the execution time of Delphi code in TMS WEB Core.
So how does window.Performance
and window.performance.now()
work in Delphi?