era269/micro-object

对象 <=> 服务 => 微服务 <=> 微对象

0.10.0 2021-05-22 21:29 UTC

This package is auto-updated.

Last update: 2024-09-10 01:18:58 UTC


README

PHP Stan Badge codecov

面向对象编程

该库仅提供消息处理和事件分发的功能。示例中只描述了一个情况。请参阅

  • NotebooksPort.php
  • NotebookPortTest.php

process

性能

使用了修改的 \Era269\Microobject\Example\Tests\NotebookPortTest::testGetText 方法

缓存

默认 \Era269\Microobject\Traits\CanGetMethodNameByMessageTrait 功能

    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']);
    }

输出

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

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

 end: 

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

无缓存

修改的 \Era269\Microobject\Traits\CanGetMethodNameByMessageTrait 功能

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

输出

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

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

 end: 

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