I use the Timer function in VBA to help identify any problems in my code. After the code is triggered, I set startTime = Timer. My code’s first job is to lift the data that is imported from Gruss to Excel into an array. Once the bot has done its thing, the array is pasted back into excel with any triggers/new data added (so my code only does 1x excel read and 1x excel write). The last thing it does before the paste instruction is to add the time taken to run the code to an unused cell in the array area – stopTime = Timer – startTime. This is just to provide a visual indication while I’m watching, to see what’s happening and if there’s any blockages.
Since I’ve recoded, the time reported is rarely anything other than zero. But zero what? What is zero? What is the resolution of the built in Timer function? I initially read that the Timer counted in 1/64ths of a second. Which is 0.015625 seconds. This made sense, as this is a number I’ve seen flash up on the sheet as the bot was running (I actually saw 0.0156 due to cell format). It would normally bounce between this and zero.
This means my code is running, normally, in less than 0.02 seconds. The shortest interval between price update I’ve observed on Gruss, when on full stream, is around 0.1 seconds (up to 10 refreshes per second). So I know my code is running fast enough not to be missing any data refreshes. That’s good.
An interesting observation from the VPS – I’ve seen, though not often, the reported time as 0.0078. this looks like half of 1/64th, and it is. 1/128th seconds is 0.0078125.
My conclusion is that the Timer function is actually linked to the hardware and/or the operating system, and therefore may differ depending on your set up.