Created
February 19, 2022 13:23
-
-
Save percybolmer/5a68d840ec5a00adc3dc510fe7f8dd91 to your computer and use it in GitHub Desktop.
A set of functions to Benchmark
This file contains hidden or 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
package functions | |
// Subtract will subtract the second value from the first | |
func SubtractInt(a, b int) int { | |
return a - b | |
} | |
// Subtract64 will subtract the second value from the first | |
func SubtractInt64(a, b int) int { | |
return a - b | |
} | |
// SubtractFloat32 will subtract the second value from the first | |
func SubtractFloat32(a, b float32) float32 { | |
return a - b | |
} | |
// SubtractTypeSwitch is used to subtract using interfaces | |
func SubtractTypeSwitch(a, b interface{}) interface{} { | |
switch a.(type) { | |
case int: | |
return a.(int) - b.(int) | |
case int64: | |
return a.(int64) - b.(int64) | |
case float32: | |
return a.(float32) - b.(float32) | |
default: | |
return nil | |
} | |
} | |
// Subtract will subtract the second value from the first | |
func Subtract[V int64 | int | float32](a, b V) V { | |
return a - b | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment