Created
July 31, 2013 15:37
-
-
Save olih/6123110 to your computer and use it in GitHub Desktop.
Basic calculation of cost/revenue by page viewed
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
# | |
#Creator: 2013, Olivier Huin (https://github.com/olih) | |
#License: Eclipse Public License - v 1.0 | |
#Contributors: | |
# | |
#Very basic page view cost calculator | |
#Dollar conversion | |
D= 0.65 | |
#Euro conversion | |
E= 0.86 | |
#Pound conversion | |
P= 1 | |
#Gigabyte | |
K= 1024 | |
googleSiteSearch = (queries) -> queries*250*D/50000 | |
averageTopGoogleCostPerClick = (queries) -> queries*32*D | |
perClickRevenueClicksor = (queries) -> queries*0.035*D | |
#number of queries | |
cost= (queries)-> | |
r = {} | |
r["googleSiteSearch"]= googleSiteSearch(queries) | |
r["averageTopGoogleCostPerClick"]= averageTopGoogleCostPerClick(queries) | |
r["perClickRevenueClicksor"]= perClickRevenueClicksor(queries) | |
return r | |
rangeCost= (minQ,maxQ,incr, f1)-> | |
r = {} | |
queries = minQ | |
while queries<=maxQ | |
c=f1(queries) | |
unit = if queries<K then "" else "K" | |
unitVal = if queries<K then queries else queries/K | |
r[unitVal+" "+unit]=c | |
queries=queries+incr | |
return r | |
#Calculates the cost for an increase in traffic | |
console.log "Cost is in pounds for queries" | |
console.log rangeCost(10*K,100*K,10*K, cost) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment