paulgutten
paulgutten

Reputation: 309

estimate performance gain based on application profiling (math)

this question is rather "math" related - but certainly is of interest to any "software developer".

i have done some profiling of my application. and i have observed there is a huge performance difference that is "environment specific".
there is a "fast" environment and a "slow" environment.

so let's assume i will be able to reduce invoking this particular function by 50 percent.

how do i calculate the estimated performance improvement on the "slow" environment?
is there any approximate formula for calculating the expected performance gain?

apologies:
nowadays i'm no longer good at doing any math. or rather i never was!
i have been thinking about where to ask such question, best.
didn't come up with any more suitable place.
also, i wasn't able to come up with an optimal question's subject line and also what tags to assign ...

Upvotes: 0

Views: 66

Answers (1)

Mike Dunlavey
Mike Dunlavey

Reputation: 40659

Let's make an assumption (questionable but we have nothing else to go on). Let's assume all of the 5:1 reduction in time is due to function foo reducing by 18:1. That means everything else in the program takes the same amount of time.

So suppose in the fast environment the total time is f + x, where f is the time that foo takes in the fast environment, and x is everything else.

In the slow environment, the time is 18f+x, which equals 5(f+x). OK, solve for x.

18f+x = 5f+5x

13f = 4x

x = 13/4 f

OK, now on the slow environment you want to call foo half as much. So then the time would be 9f+x, which is:

9f + 13/4 f = 49/4 f

The original time was 18f+x = (18+13/4)f = 85/4 f

So the time goes from 85/4 f to 49/4 f. That's a speed ratio of 85/49 = 1.73

In other words, that's a speedup of 73%.

Upvotes: 1

Related Questions