Skip to content

Instantly share code, notes, and snippets.

@gloriousCode
Created September 24, 2020 23:22
Show Gist options
  • Save gloriousCode/088cac8eedc6a70d8d9ea5e32aaad239 to your computer and use it in GitHub Desktop.
Save gloriousCode/088cac8eedc6a70d8d9ea5e32aaad239 to your computer and use it in GitHub Desktop.
func Setup() *Engine {
engerino := new(Engine)
engerino.Config = &config.Cfg
err := engerino.Config.LoadConfig(config.TestFile, true)
if err != nil {
}
exch := engerino.GetExchangeByName(testExchange)
if exch == nil {
err = engerino.LoadExchange(testExchange, false, nil)
if err != nil {
}
for i := range engerino.Config.Exchanges {
engerino.Config.Exchanges[i].API.Credentials.OTPSecret = "hellomoto"
}
}
return engerino
}
func BenchmarkOTP(b *testing.B) {
engerino := Setup()
b.ResetTimer()
for n := 0; n < b.N; n++ {
otp, err := engerino.GetExchangeoOTPByName(testExchange)
if err == nil {
_, errParse := strconv.ParseInt(otp, 10, 64)
if errParse != nil {
b.Error("failed to generate OTP unable to continue")
}
}
}
}
func BenchmarkGetExchangeByName(b *testing.B) {
engerino := Setup()
b.ResetTimer()
for n := 0; n < b.N; n++ {
_ = engerino.GetExchangeByName(testExchange)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment