Hi @temurbek –
An instruction is a WebAssembly instruction. You can’t measure this by looking at your source code directly. However you can use Shopify CLI to execute your function locally and measure it. You can use standard language tools to measure and optimize the performance of your code.
There are cases with large orders that may be difficult to handle with Functions today. We have plans to address this. But 10 products should be manageable. Do you have a very large amount of data (e.g. metafields) being returned with each product? Or are you writing console logs on every loop through the cart potentially?
-Nick