Synthetics Stop Watch

Does anyone know if there is a stop watch function that can be used with Synthetics?

Hi @BigNStrauss - Can I ask why you would use the stop watch? If it is to check page load times or to ensure that the test runs within a specific time then you could use my sample script as a basis and put a check in for start and end times which fails the test if it exceeds your limit.

@stefan_garnham Cool thanks! I’ll check it out.

@stefan_garnham Sorry this is a bit past when you replied, but I finally got around to implementing your stop watch suggestion but I get an error. Using this:

 var startTime = new Date();
 var elapsedSecs = (new Date() - startTime);

I get an error on (new Date() - startTime); saying that “The left-hand side of an arithmetic operation must be of type ‘any’, ‘number’ or an enum type.” It appears to me that mathematical operations can’t be applied on dates. How is yours working?

Oh that is an old script prior to when New Relic started validating the script in the editor. It will display errors in the editor but should still run fine.

I just tried actually running the test despite the errors. You’re right, it does still work. Cool, thanks!