era269/micro-object

Object <=> Service => MicroService <=> Microobject

0.10.0 2021-05-22 21:29 UTC

This package is auto-updated.

Last update: 2024-11-10 01:54:31 UTC


README

PHP Stan Badge codecov

OOP

The library just gives functionality of Message Prcessing and Event Dispatching. Only one case is described in the Example. See:

  • NotebooksPort.php
  • NotebookPortTest.php

process

Performance

was used modified \Era269\Microobject\Example\Tests\NotebookPortTest::testGetText method

Cached

default \Era269\Microobject\Traits\CanGetMethodNameByMessageTrait functionality

    public function testGetText(EventStorageInterface $eventStorage): void
    {
        $notebooksPort = $this->getAutowiredNotebookPort($eventStorage);

        echo "\n start: " . var_dump($start = hrtime()) . "\n";
        for ($i = 0; $i <= 1000; $i++) {
            $normalizedTextResponse = $notebooksPort
                ->getText([
                    'notebookId' => self::UNIQUE_ID_NOTEBOOK,
                    'pageId' => self::UNIQUE_ID_PAGE,
                ]);
        }
        echo "\n end: " . var_dump($end = hrtime()) . "\n";
        printf("\n ----------------time-------\n %d.%d ms \n", $end[0] - $start[0], abs($end[1] - $start[1]));

        $expectedText = [
            'first line',
            'second line',
            'third line',
        ];

        self::assertEquals($expectedText, $normalizedTextResponse['payload']['lines']);
    }

output:

array(2) {
  [0]=>
  int(131238)
  [1]=>
  int(855914676)
}

 start: 
array(2) {
  [0]=>
  int(131238)
  [1]=>
  int(888507531)
}

 end: 

 ----------------avereage-time-------
 0.32592855 ms 

Without any cache:

modified \Era269\Microobject\Traits\CanGetMethodNameByMessageTrait functionality

    private static function getMap(string $className): array
    {
//        if (!empty(static::$methodNamesMap[$className])) {
//            return static::$methodNamesMap[$className];
//        }

output:

array(2) {
  [0]=>
  int(131658)
  [1]=>
  int(190087943)
}

 start: 
array(2) {
  [0]=>
  int(131658)
  [1]=>
  int(275028022)
}

 end: 

 ----------------avereage-time-------
 0.84940079 ms