Skip to content

tpc http and websocket performance benchmark testing components

License

Notifications You must be signed in to change notification settings

beetlex-io/NetBenchmark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

NetBenchmark

tpc http and websocket performance benchmark components

package

https://www.nuget.org/packages/BeetleX.NetBenchmark/

tcp

    class Program
    {
        static void Main(string[] args)
        {
            var data = StringPacket.RamdomString(512);
            var runer = Benchmark.Tcp<StringPacket, Program>("192.168.2.19", 9090, 200,
                async (tcp, token) =>
                {
                    tcp.Send(data);
                    await tcp.Receive();
                }
            );
            runer.Run();
            runer.Print();
        }
    }

tcp results

image

http

    class Program
    {
        static void Main(string[] args)
        {
            var runer = Benchmark.Http<Program>(new Uri("http://192.168.2.19:5000"), 100,
                async (http, token) =>
                {
                    await http.Get("/api/values");
                    await http.PostJson("/api/values", "beetlex.io");
                });
            runer.Run();
            runer.Print();
        }
    }

http result

image

websocket

    class Program
    {
        static void Main(string[] args)
        {
            var runer = Benchmark.WebsocketJson<Program>(new Uri("ws://192.168.2.19:8080"), 100,
                async (ws, token) =>
                {
                    ws.TimeOut = 1000 * 5;
                    ws.Send(new { url = "/json" });
                    var result = await ws.Receive();
                });
            runer.Run();
            runer.Print();
        }
    }

result

image