Are you doing the sampling every second (like through setInterval()) or in real-time (with the render cycle)? But more importantly, what kind of TerrainProvider have you got there? It looks like a WMS (or web service) instead of, for example, a DTM. I guess a bit more info about your actual data would help.
But I’m also curious as to why you write calls to the API this way and what the getMap() function does;
Why the [‘’] notation, any particular reason? Also, could there be extra time spent in .getMap()? The sampling is a bit slow, and I guess you could have a stab at using slightly different methods (for example creating your own ray and test intersection), however I doubt that will get you much. I think firstly you need to tell us about the terrain provider and the data itself (what is it, where does it come from, etc.)
I put together a little Sandcastle example that I think roughly mirrors what you’re trying to do.
On my browser, each call takes 30-100ms, which does seem a bit high, and creates a network request to the terrain service, though the devtools say they resolve in a couple ms because the file is cached. Maybe the service you’re using for terrain doesn’t set the correct headers to ensure tiles are cached by the browser? (I do agree that Cesium could probably do some application-level caching here…)