redisLoadTest/redisLoadTest.go

55 lines
1.7 KiB
Go
Raw Normal View History

2021-12-25 05:49:07 +00:00
package main
2021-12-29 15:54:43 +00:00
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <mitch@nerdfortress.dev> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return
* ----------------------------------------------------------------------------
*/
2021-12-25 05:49:07 +00:00
import (
"flag"
"fmt"
"time"
)
func main() {
hostPtr := flag.String("host", "", "Redis Server FQDN:port")
usernamePtr := flag.String("username", "", "Redis Server username")
passwordPtr := flag.String("password", "", "Redis user password")
2021-12-25 05:49:07 +00:00
//dbPtr := flag.Int("db", 0, "Redis db, default 0")
initializeDBPtr := flag.Bool("initialize", false, "Boolean initialize db, default false")
ratePtr := flag.Int("rate", 5, "Test rate limit, default 50/sec")
burstPtr := flag.Bool("burst", false, "Boolean burst test default true")
2021-12-25 05:49:07 +00:00
//todo this should be off that same csv rather than an input
maxEntriesPtr := flag.Int("dbEntries", 50000, "Test rate limit, default 50/sec")
2021-12-29 15:54:43 +00:00
testDurationPtr := flag.Int("duration", 10, "Duration of each test")
2021-12-25 05:49:07 +00:00
2021-12-29 15:54:43 +00:00
flag.Parse()
2021-12-25 05:49:07 +00:00
host := *hostPtr
username := *usernamePtr
password := *passwordPtr
2021-12-25 05:49:07 +00:00
//db := *dbPtr
initializeDB := *initializeDBPtr
rate := *ratePtr
burst := *burstPtr
keyMaxValue := *maxEntriesPtr
durationInt := *testDurationPtr
2021-12-26 23:52:03 +00:00
duration := time.Second * time.Duration(durationInt)
2021-12-25 05:49:07 +00:00
pool := newPool(host, username, password)
2021-12-25 05:49:07 +00:00
client := pool.Get()
defer client.Close()
if initializeDB {
2021-12-25 05:49:07 +00:00
buildTestData(&client, 50000)
}
getRateTest(&client, rate, keyMaxValue, duration)
2021-12-25 05:49:07 +00:00
if burst {
getBurstTest(&client, rate, keyMaxValue, duration)
2021-12-25 05:49:07 +00:00
}
fmt.Println("Tests completed...")
}