Created
April 9, 2018 18:59
-
-
Save ryanshoover/f7a56648389b3883d50151bbf6be11d9 to your computer and use it in GitHub Desktop.
Calculate revenue difference for a faster site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Calculate the difference in revenue I should experience | |
* if my load time changes. | |
* | |
* Based on the assumption that every second of page load | |
* causes a 7% drop in conversions. | |
* | |
* Formula in LaTex: [ R = \frac{ R_p }{ {e}^{\ln(0.93) T_p} }\ e^{\ln(0.93) T_c} - R_p ] | |
* | |
* @param float $revenue_current Current revenue for the site. | |
* @param float $load_time_current Current load time for the site. | |
* @param float $load_time_new Projected new load time for the site. | |
* @return float Projected difference in revenue for the site. | |
*/ | |
function calc_revenue_gain( $revenue_current = 50000, $load_time_current = 5, $load_time_new = 2 ) { | |
$revenue_new = $revenue_current / ( exp( log( 0.93 ) * $load_time_current ) ) * exp( log( 0.93 ) * $load_time_new ); | |
return $revenue_new - $revenue_current; | |
} | |
echo calc_revenue_gain( 50000, 5, 2 ) . PHP_EOL; | |
echo calc_revenue_gain( 30000, 10, 3 ) . PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment