mirror of
https://github.com/boostorg/redis.git
synced 2026-01-19 04:42:09 +00:00
Adds go-redis
This commit is contained in:
@@ -15,6 +15,41 @@
|
||||
% and
|
||||
% http://www.ctan.org/tex-archive/graphics/pgf/contrib/pgfplots/doc/latex/plotdata/
|
||||
|
||||
|
||||
% $ time ./echo_server_client 1000 5000
|
||||
% ======================================================
|
||||
% C++: Asio
|
||||
%
|
||||
% Seq: 216.000s = 3.54 * Async.
|
||||
% Direct: 31.427s
|
||||
% Over Redis: 61.394s
|
||||
%
|
||||
% ======================================================
|
||||
% C++: libuv
|
||||
%
|
||||
% real 0m43.568s
|
||||
%
|
||||
% ======================================================
|
||||
% Rust: Tokio
|
||||
%
|
||||
% Seq: 186.000s = 1.3 * Async.
|
||||
% Direct: 42.214s
|
||||
% Over Redis: 142.775s
|
||||
%
|
||||
% ======================================================
|
||||
% Go
|
||||
%
|
||||
% Direct: 78.238s
|
||||
% Over Redis: 54.238s
|
||||
%
|
||||
% ======================================================
|
||||
% Nodejs
|
||||
%
|
||||
% Seq: 360.000s = 2.6 * Async.
|
||||
% Direct: 72.973s
|
||||
% Over Redis: 141.881s
|
||||
|
||||
|
||||
\usepackage{pgfplots}
|
||||
\pgfplotsset{compat=newest}
|
||||
|
||||
|
||||
53
benchmarks/go/echo_server_over_redis.go
Normal file
53
benchmarks/go/echo_server_over_redis.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/go-redis/redis/v8"
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"os"
|
||||
)
|
||||
|
||||
var ctx = context.Background()
|
||||
var rdb = redis.NewClient(&redis.Options{Addr: "localhost:6379", Password: "", DB: 0,})
|
||||
|
||||
func echo(conn net.Conn) {
|
||||
r := bufio.NewReader(conn)
|
||||
for {
|
||||
line, err := r.ReadBytes(byte('\n'))
|
||||
switch err {
|
||||
case nil:
|
||||
break
|
||||
case io.EOF:
|
||||
default:
|
||||
fmt.Println("ERROR", err)
|
||||
}
|
||||
|
||||
err2 := rdb.Ping(ctx).Err()
|
||||
if err2 != nil {
|
||||
panic(err2)
|
||||
}
|
||||
|
||||
conn.Write(line)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
l, err := net.Listen("tcp", "0.0.0.0:55555")
|
||||
if err != nil {
|
||||
fmt.Println("ERROR", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
for {
|
||||
conn, err := l.Accept()
|
||||
if err != nil {
|
||||
fmt.Println("ERROR", err)
|
||||
continue
|
||||
}
|
||||
|
||||
go echo(conn)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user