theLink 10.0 NHI1 - theKernel - theLink - theConfig - theSq3Lite - theCompiler - theBrain - theGuard
c - tcl - cs - py - rb - jv - cc
Loading...
Searching...
No Matches
Example: perfserver

Documentation of the perfserver tool used for example.test.

INTRODUCTION

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 tclmqmsgque protocoll and build together a flat-like structure.

The GOAL for this setup is:

CODE server

#!/usr/bin/env tclsh
#+
#:   @file         NHI1/example/tcl/perfserver.tcl
#:   @brief        perfserver.tcl - 22 Aug 2024 - aotto1968
#:   @copyright    (C) NHI - #1 - Project - Group
#:                 This software has NO permission to copy,
#:                 please contact AUTHOR for additional information
#:   @version      a24cb4ee95f683e7e0be49a73f2064e206065bbe
#:   @date         Thu Aug 22 23:26:33 2024 +0200
#:   @author       aotto1968 <aotto1968@t-online.de>
#:

package require tclmqmsgque
namespace import tclmqmsgque::*
namespace import tclmkkernel::*

::oo::class create perfserver {
  superclass MqContextC

  method Ot_ECOU {} {
    my SendSTART
    my SendBUF [my ReadBUF]
    my SendRETURN
  }

  method Ot_ECOI {} {
    my SendSTART
    my SendI32 [my ReadI32]
    my SendRETURN
  }

  method Ot_ECUL {} {
    my SendSTART
    my SendI8 [my ReadI8]
    my SendI16 [my ReadI16]
    my SendI32 [my ReadI32]
    my SendDBL [my ReadDBL]
    my ProxyItem [self]
    my SendRETURN
  }

  method Ot_RDUL {} {
    my ReadI8
    my ReadI16
    my ReadI32
    my ReadDBL
    my ReadBUF
  }

  method Ot_RDUC {} {
    my ReadSTR
    my ReadSTR
    my ReadSTR
    my ReadSTR
    my ReadSTR
  }

  method Ot_STDB {} {
    my SendSTART
    my StorageOpen [my ReadSTR]
    my SendRETURN
  }

  method Ot_STDC {} {
    my SendSTART
    my StorageClose
    my SendRETURN
  }

  # [BufferStream-Create-TLS]
  method Ot_BUST {} {
    set bus [MkBufferStreamC CreateTLS "perfserver-BUST" ]
    while {[my ReadItemExists]} {
      $bus WriteBUF [my ReadBUF]
    }
    $bus PosToStart
    my SendSTART
    while {[$bus ReadItemExists]} {
      my SendBUF [$bus ReadBUF]
    }
    my SendRETURN
  }
  # [BufferStream-Create-TLS]

  # [BufferList-Create-TLS]
  method Ot_BFLT {} {
    set bfl [MkBufferListC CreateTLS "perfserver-BFLT" ]
    while {[my ReadItemExists]} {
      $bfl AppendBUF [my ReadBUF]
    }
    my SendSTART
    set size [$bfl Size]
    for {set i 0} {$i < $size} {incr i} {
      my SendBUF [$bfl IndexGet $i]
    }
    my SendRETURN
  }
  # [BufferList-Create-TLS]

  method Ot_BINT {} {
    my ReadBIN
  }

  method Ot_STRT {} {
    my ReadSTR
  }

  method Ot_NTHT {} {
  }

  method serverSetup {} {
    my ServiceCreate ECOU Ot_ECOU
    my ServiceCreate ECOI Ot_ECOI
    my ServiceCreate ECUL Ot_ECUL
    my ServiceCreate RDUL Ot_RDUL
    my ServiceCreate RDUC Ot_RDUC
    my ServiceCreate STDB Ot_STDB
    my ServiceCreate STDC Ot_STDC
    my ServiceCreate BUST Ot_BUST
    my ServiceCreate BFLT Ot_BFLT
    my ServiceCreate BINT Ot_BINT
    my ServiceCreate STRT Ot_STRT
    my ServiceCreate NTHT Ot_NTHT
  }

  # factory startup (constructor)
  constructor {{tmpl ""}} {
    next $tmpl
    my ConfigSetServerSetup serverSetup
  }
} 

tclmqmsgque::Main {

  # setup commandline arguments for later use
  set largv  [MkBufferListC CreateLA {*}$argv]

  # [factory-item]
  # create "perfserver" factory... and make it to the default.
  [MqFactoryC Add perfserver] Default
  # [factory-item]

  # inspect commandline-argument for the "factory" to choose... and create a new instance
  set srv   [ [MqFactoryC GetCalledL $largv] New ]

  try {
    $srv LinkCreate $largv
    $srv ProcessEvent MQ_WAIT_FOREVER
  } on error {} {
    $srv ErrorCatch
  } finally {
    $srv Exit
  }
}