From 1a313ef66748452fe14b51e119cbeaa44a956102 Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Sat, 4 Jul 2020 20:10:10 -0400 Subject: [PATCH] Add performance section --- README.md | 70 ++++++++++++++++++++++++++++++++++++++++++++++ examples/server.go | 2 +- 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index edccfa2..a50b91f 100644 --- a/README.md +++ b/README.md @@ -95,3 +95,73 @@ Any Redis client should be able to interact with the server, though only the fol - [ ] KEYS - [ ] EXISTS - [ ] ECHO + + +## Performance + +Using the following command: +``` +redis-benchmark -p 6379 -t set,get -n 10000000 -q -P 512 -c 512 +``` + +On a machine with the following specs: +``` +Arch Linux +x86_64 Linux 5.7.7-arch1-1 +i7-8550U 8x 4GHz +16G RAM +``` + +### Gocache + +#### Without eviction + +With the following configuration: +``` +cache := gocache.NewCache().WithEvictionPolicy(gocache.LeastRecentlyUsed).WithMaxSize(10000000) +server := gocacheserver.NewServer(cache) +server.Start() +``` + +Single-threaded (`GOMAXPROCS=1 go run examples/server.go`): +``` +SET: 2239727.50 requests per second +GET: 2681068.00 requests per second +``` + +Multi-threaded (`go run examples/server.go`): +``` +SET: 2573476.00 requests per second +GET: 6399190.50 requests per second +``` + +#### With eviction + +With the following configuration: +``` +cache := gocache.NewCache().WithEvictionPolicy(gocache.LeastRecentlyUsed).WithMaxSize(10000) +server := gocacheserver.NewServer(cache) +server.Start() +``` + +Single-threaded (`GOMAXPROCS=1 go run examples/server.go`): +``` +SET: 2305298.50 requests per second +GET: 2745096.00 requests per second +``` + +Multi-threaded (`go run examples/server.go`): +``` +SET: 2576740.00 requests per second +GET: 6451397.00 requests per second +``` + + +### Redis + +Using the default configuration with `redis-server`: +``` +SET: 2105156.50 requests per second +GET: 2842900.75 requests per second +``` + diff --git a/examples/server.go b/examples/server.go index bc66806..a9effd1 100644 --- a/examples/server.go +++ b/examples/server.go @@ -6,7 +6,7 @@ import ( ) func main() { - cache := gocache.NewCache() + cache := gocache.NewCache().WithEvictionPolicy(gocache.LeastRecentlyUsed).WithMaxSize(10000) server := gocacheserver.NewServer(cache) server.Start() }