-
-
Save slang25/97290a68383c4d02b6a2f5df860efb74 to your computer and use it in GitHub Desktop.
Calculates the cost of an Azure Container Instances container
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
// Calculates the cost of an Azure Container Instances container | |
// Using the default Linux container with 1 vCpu and 1.5GB vRAM | |
[<Measure>] type gb | |
[<Measure>] type cores | |
[<Measure>] type sec | |
[<Measure>] type hour | |
[<Measure>] type pound | |
[<Measure>] type gbPerSec = gb/sec | |
[<Measure>] type corePerSec = cores/sec | |
let gbCost = 0.0000038<pound/(gb sec)> | |
let coreCost = 0.0000112<pound/(cores sec)> | |
let secondsPerHour = 60. * 60.<sec/hour> | |
let calculateRatePerSecond (memoryInGb:float<gb>) (numCores: float<cores>) = | |
(memoryInGb * gbCost) + (numCores * coreCost) | |
let calculateHourlyRate (memoryInGb:float<gb>) (numCores: float<cores>) = | |
let costPerSec = calculateRatePerSecond memoryInGb numCores | |
costPerSec * secondsPerHour | |
calculateHourlyRate 1.5<gb> 1.0<cores> |> printfn "%f" | |
// 0.6p / hour | |
// £1.46 / day | |
// £43.80 / month |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment