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

The GOAL for this setup is:

CODE server

<?php
#+
#:   @file         example/php/perfserver.php
#:   @brief        perfserver.php - 03 May 2023 - aotto1968
#:   @copyright    (C) NHI - #1 - Project - Group
#:                 This software has NO permissions to copy,
#:                 please contact AUTHOR for additional information
#:   @version      1c3a8f89f6bbd5c146252125f8a426400f6e1300
#:   @date         Wed May 3 12:28:13 2023 +0200
#:   @author       aotto1968 <aotto1968@t-online.de>
#:

use PhpMsgque\MqMsgque as mq;
use PhpMsgque\MkKernel as mk;

class perfserver extends mq\MqContextC implements mq\iServerSetup {
  public function ServerSetup() {
    $this->ServiceCreate('ECOU', 'ECOU');
    $this->ServiceCreate('ECOI', 'ECOI');
    $this->ServiceCreate('ECUL', 'ECUL');
    $this->ServiceCreate('RDUL', 'RDUL');
    $this->ServiceCreate('RDUC', 'RDUC');
    $this->ServiceCreate('STDB', 'STDB');
    $this->ServiceCreate('STDC', 'STDC');
    $this->ServiceCreate('BUST', 'BUST');
    $this->ServiceCreate('BFLT', 'BFLT');
    $this->ServiceCreate('BINT', 'BINT');
    $this->ServiceCreate('STRT', 'STRT');
  }

  public function ECOU() {
    $this->SendSTART();
    $this->SendU($this->ReadU());
    $this->SendRETURN();
  }

  public function ECOI() {
    $this->SendSTART();
    $this->SendI($this->ReadI());
    $this->SendRETURN();
  }

  public function ECUL() {
    $this->SendSTART();
    $this->SendY($this->ReadY());
    $this->SendS($this->ReadS());
    $this->SendI($this->ReadI());
    $this->SendD($this->ReadD());
    $this->ProxyItem($this);
    $this->SendRETURN();
  }

  public function RDUL() {
    $this->ReadY();
    $this->ReadS();
    $this->ReadI();
    $this->ReadD();
    $this->ReadU();
  }

  public function RDUC() {
    $this->ReadC();
    $this->ReadC();
    $this->ReadC();
    $this->ReadC();
    $this->ReadC();
  }

  public function STDB() {
    $this->SendSTART();
    $this->StorageOpen($this->ReadC());
    $this->SendRETURN();
  }

  public function STDC() {
    $this->SendSTART();
    $this->StorageClose();
    $this->SendRETURN();
  }

  # [BufferStream-Create-TLS]
  public function BUST() {
    $bus = mk\MkBufferStreamC::CreateTLS(0);
    while ($this->ReadItemExists()) {
      $bus->WriteU($this->ReadU());
    }
    $bus->PosToStart();
    $this->SendSTART();
    while ($bus->ReadItemExists()) {
      $this->SendU($bus->ReadU());
    }
    $this->SendRETURN();
  }
  # [BufferStream-Create-TLS]

  # [BufferList-Create-TLS]
  public function BFLT() {
    $bfl = mk\MkBufferListC::CreateTLS(0);
    while ($this->ReadItemExists()) {
      $bfl->AppendU($this->ReadU());
    }
    $this->SendSTART();
    foreach (range(0, $bfl->Size()-1) as $i) {
      $this->SendU($bfl->IndexGet($i));
    }
    $this->SendRETURN();
  }
  # [BufferList-Create-TLS]

  public function BINT() {
    $this->ReadB();
  }

  public function STRT() {
    $this->ReadC();
  }
}

# setup commandline arguments for later use
$largv = mk\MkBufferListC::CreateLA($argv);

# [factory-item]
# create "perfserver" factory... and make it to the default.
mq\MqFactoryC::Add("perfserver")->Default();
# [factory-item]

# inspect commandline-argument for the "factory" to choose... and create a new instance
$srv = mq\MqFactoryC::GetCalledL($largv)->New();

try {
  $srv->LinkCreate($largv);
  $srv->ProcessEvent(mq\MqWaitOnEventE::FOREVER);
} catch (Throwable $ex) {
  $srv->ErrorCatch($ex);
} finally {
  $srv->Exit();
}

?>