2
0
mirror of https://github.com/boostorg/redis.git synced 2026-01-19 04:42:09 +00:00

Updates the go benchmark.

This commit is contained in:
Marcelo Zimbres
2022-08-25 21:24:23 +02:00
parent 8249360a52
commit f11622e746
3 changed files with 18 additions and 18 deletions

View File

@@ -34,7 +34,7 @@ decrease.
* I did expect nodejs to come a little behind given it is is * I did expect nodejs to come a little behind given it is is
javascript code. Otherwise I did expect it to have similar javascript code. Otherwise I did expect it to have similar
performance to libuv since it is the framework behind it. performance to libuv since it is the framework behind it.
* Go performance did not surprise me: decent and not some much far behind nodejs. * Go did surprise me: faster than nodejs and liuv!
The code used in the benchmarks can be found at The code used in the benchmarks can be found at

View File

@@ -17,7 +17,7 @@
width=15cm, height=6cm, enlarge y limits=0.5, width=15cm, height=6cm, enlarge y limits=0.5,
title={TCP Echo Server Performance}, title={TCP Echo Server Performance},
xlabel={Seconds}, xlabel={Seconds},
symbolic y coords={Asio,Tokio,Libuv,Nodejs,Go}, symbolic y coords={Asio,Tokio,Go,Libuv,Nodejs},
ytick=data, ytick=data,
%bar width=1cm, %bar width=1cm,
nodes near coords, nodes near coords,
@@ -26,18 +26,16 @@
\addplot coordinates { \addplot coordinates {
(31.1,Asio) (31.1,Asio)
(30.7,Tokio) (30.7,Tokio)
(35.6,Go)
(43.6,Libuv) (43.6,Libuv)
(74.2,Nodejs) (74.2,Nodejs)
(81.0,Go)
}; };
\end{axis} \end{axis}
\end{tikzpicture} \end{tikzpicture}
\endpgfgraphicnamed \endpgfgraphicnamed
\beginpgfgraphicnamed{echo-f1} \beginpgfgraphicnamed{echo-f1}
%debian2[0]$ time ./echo_server_client 1000 1000 %$ time ./echo_server_client 1000 1000
%Go (1): 1.000s
%C++ (1): 0.07s
\begin{tikzpicture}[scale=1.0] \begin{tikzpicture}[scale=1.0]
\begin{axis}[ \begin{axis}[
y dir=reverse, y dir=reverse,

View File

@@ -1,29 +1,31 @@
package main package main
import ( import (
"bufio"
"fmt" "fmt"
"io"
"net" "net"
"os" "os"
"runtime"
) )
func echo(conn net.Conn) { func echo(conn net.Conn) {
r := bufio.NewReader(conn) buf := make([]byte, 1024)
for { for {
line, err := r.ReadBytes(byte('\n')) n, err := conn.Read(buf)
switch err { if err != nil {
case nil: break;
break }
case io.EOF:
default: conn.Write(buf[:n])
fmt.Println("ERROR", err) if err != nil {
} fmt.Println("ERROR", err)
conn.Write(line) os.Exit(1)
}
} }
} }
func main() { func main() {
runtime.GOMAXPROCS(1)
l, err := net.Listen("tcp", "0.0.0.0:55555") l, err := net.Listen("tcp", "0.0.0.0:55555")
if err != nil { if err != nil {
fmt.Println("ERROR", err) fmt.Println("ERROR", err)