CakePHP3에서 처리 실행 시간을 측정하는 간단한 방법

3766 단어 CakePHPcakephp3

CakePHP3에서 처리 실행 시간을 측정하는 간단한 방법



어디에 시간이 걸리고 있는지, 각 처리의 실행 시간을 계측하고 싶을 때, 있지요?

그러한 때, 여러가지 계측 방법이 있다고 생각합니다만, CakePHP3로, 손쉽게 계측하고 싶을 때는 \DebugKit\DebugTimer 를 사용하면 편합니다.

측정 코드 설치


\DebugKit\DebugTimer::start()\DebugKit\DebugTimer::stop() 를 꽂습니다. 첫 번째 인수가 키이므로 맞추십시오.
<?php
    -snip-
    public function edit($id = null)
    {
        \DebugKit\DebugTimer::start('post_get', 'データ取得'); // 計測スタート
        $post = $this->Posts->get($id, [
            'contain' => ['Tags']
        ]);
        \DebugKit\DebugTimer::stop('post_get'); // 計測終了
        if ($this->request->is(['patch', 'post', 'put'])) {
            $post = $this->Posts->patchEntity($post, $this->request->data);
            if ($this->Posts->save($post)) {
                $this->Flash->success(__('The post has been saved.'));
    - snip -

런타임 확인



DebugKit의 Timer 패널을 확인해보십시오.



「데이터 취득」이라고 하는 행이 증가하고 있군요.
중첩 측정도 가능합니다.

락-.

좋은 웹페이지 즐겨찾기