Background: there'a a gazillion types of virtual machines in Microsoft Azure each having different performance and price. Such virtual machines are paid per hour. The goal is to decide how to get "the most for the money spent". This can be also reworded in terms of electricity spent for a certain amount of computation.
So I have a piece of code as here which is highly CPU-intensive - uses little memory and no disk. My goal is comparing processor speed only and I assume that the code I use mostly uses the same CPU instructions sequences as the production load I plan for so it makes sense to use this code in the first place. I select the parameter (the number of the value to compute) for that code and it's unchanged across runs - let it be "five million" - and so all runs compute exactly the same.
So I run this code multiple times on VM of type T1 (imaginary, no such VM type in Azure now) and I see that it runs for 5 minutes on average. T1 machines cost 10 cents per hour.
Then I run this code multiple times on VM of type T2 and I see that it runs for 7.5 minutes on average. T2 machines cost 8 cents per hour.
I then must somehow compare which is better. My logic is the following: we're interested in minimizing both the time and the cost. So we can multiply the time to run the code by the cost per hour which gives us "money-by-time" (cents-by-minutes in this specific comparison) measure. A VM with the smallest "money-by-time" value is the most efficient. In this case T1 machines has "5 minutes by 10 cents" (50) and T2 machine has "7.5 minutes by 8 cents" (60). T1 machine is 17 % more efficient then.
Does such way of comparing VMs in terms of performance for given price make sense? Is there perhaps any error in my logic?