Documentation of the perfserver tool used for example.test
.
The perfserver tool is used server-part of the performance-test
To perform the test the perfclient send various service request to the perfserver. The perfclient is written in C and finally create a report.
All context created, are connected using the rbmqmsgque protocoll and build together a flat-like structure.
The GOAL for this setup is:
client → server → client
round-trip.#+ #: @file NHI1/example/rb/perfserver.rb #: @brief perfserver.rb - 18 Aug 2024 - aotto1968 #: @copyright (C) NHI - #1 - Project - Group #: This software has NO permissions to copy, #: please contact AUTHOR for additional information #: @version 633c99b943854f56f10720c0377e41fcb3b1260e #: @date Sun Aug 18 14:30:16 2024 +0200 #: @author aotto1968 <aotto1968@t-online.de> #: require "rbmqmsgque" include RbMsgque::MkKernel include RbMsgque::MqMsgque class PerfServer < MqContextC # factory startup def initialize() super() ConfigSetServerSetup(method(:ServerSetup)) end def ECOU SendSTART() SendBUF(ReadBUF()) SendRETURN() end def ECOI SendSTART() SendI32(ReadI32()) SendRETURN() end def ECUL SendSTART() SendI8(ReadI8()) SendI16(ReadI16()) SendI32(ReadI32()) SendDBL(ReadDBL()) ProxyItem(self) SendRETURN() end def RDUL ReadI8() ReadI16() ReadI32() ReadDBL() ReadBUF() end def RDUC ReadSTR() ReadSTR() ReadSTR() ReadSTR() ReadSTR() end def STDB SendSTART() StorageOpen(ReadSTR()) SendRETURN() end def STDC SendSTART() StorageClose() SendRETURN() end # [BufferStream-Create-TLS] def BUST bus = MkBufferStreamC.CreateTLS( "perfserver-BUST" ) while ReadItemExists() bus.WriteBUF(ReadBUF()) end bus.PosToStart() SendSTART() while bus.ReadItemExists() SendBUF(bus.ReadBUF()) end SendRETURN() end # [BufferStream-Create-TLS] # [BufferList-Create-TLS] def BFLT bfl = MkBufferListC.CreateTLS( "perfserver-BFLT" ) while ReadItemExists() bfl.AppendBUF(ReadBUF()) end SendSTART() for i in 0...bfl.Size() SendBUF(bfl.IndexGet(i)) end SendRETURN() end # [BufferList-Create-TLS] def BINT ReadBIN() end def STRT ReadSTR() end def NTHT end def MARK DbgL(ReadSTR()) end def ServerSetup ServiceCreate("ECOU",method(:ECOU)) ServiceCreate("ECOI",method(:ECOI)) ServiceCreate("ECUL",method(:ECUL)) ServiceCreate("RDUL",method(:RDUL)) ServiceCreate("RDUC",method(:RDUC)) ServiceCreate("STDB",method(:STDB)) ServiceCreate("STDC",method(:STDC)) ServiceCreate("BUST",method(:BUST)) ServiceCreate("BFLT",method(:BFLT)) ServiceCreate("BINT",method(:BINT)) ServiceCreate("STRT",method(:STRT)) ServiceCreate("NTHT",method(:NTHT)) ServiceCreate("MARK",method(:MARK)) end end # ==================================================== # the code below is the "package-main" # setup commandline arguments for later use largv = MkBufferListC.CreateLA(ARGV) # [factory-item] # create "perfserver" factory... and make it to the default. MqFactoryC.Add(PerfServer,"perfserver").Default() # [factory-item] # inspect commandline-argument for the "factory" to choose... and create a new instance srv = MqFactoryC.GetCalledL(largv).New() begin srv.LinkCreate(largv) srv.ProcessEvent(MqWaitOnEventE::FOREVER) rescue Exception => ex srv.ErrorCatch(ex) ensure srv.Exit() end