Skip to content

Instantly share code, notes, and snippets.

@ryanshoover
Created April 9, 2018 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanshoover/f7a56648389b3883d50151bbf6be11d9 to your computer and use it in GitHub Desktop.
Save ryanshoover/f7a56648389b3883d50151bbf6be11d9 to your computer and use it in GitHub Desktop.
Calculate revenue difference for a faster site
<?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