-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#16): added support for arm architecture in cost calculation
- Loading branch information
Showing
3 changed files
with
53 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package cost | ||
|
||
var standardGBSecondX86 = map[string]float64{ | ||
"eu-central-1": 0.0000166667, | ||
} | ||
|
||
var standardGBSecondARM = map[string]float64{ | ||
"eu-central-1": 0.0000133334, | ||
} | ||
|
||
func getGBSecondPriceForArchitectureRegion(architecture, region string) float64 { | ||
if architecture == "arm64" { | ||
return standardGBSecondARM[region] | ||
} | ||
|
||
// default is x86 | ||
return standardGBSecondX86[region] | ||
} | ||
|
||
func Calculate(duration float64, memory int, architecture, region string) float64 { | ||
gbSecond := getGBSecondPriceForArchitectureRegion(architecture, region) | ||
costForMemoryInMilliseconds := (gbSecond / 1024 * float64(memory)) / 1000 | ||
|
||
return costForMemoryInMilliseconds * duration | ||
} |