Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profiler time error. #15249

Closed
cat9 opened this issue Jan 5, 2021 · 2 comments · Fixed by #15383 or #15385
Closed

Profiler time error. #15249

cat9 opened this issue Jan 5, 2021 · 2 comments · Fixed by #15383 or #15385
Assignees
Labels
5.0 The issues we want to solve in the 5.0 release bug A bug report status: medium Medium

Comments

@cat9
Copy link

cat9 commented Jan 5, 2021

return this->finalTime - this->initialTime;

The value of method(getTotalElapsedSeconds ) return is not a time in seconds.

activeProfile->setFinalTime(finalTime);

@Jeckerson
Copy link
Member

Hello

Could you please provide minimal script example?

@Jeckerson Jeckerson added the need script to reproduce Script is required to reproduce the issue label Jan 5, 2021
@cat9
Copy link
Author

cat9 commented Jan 6, 2021

hello,
you can check this function below:

public function stopProfile() -> <Profiler>

public function stopProfile() -> <Profiler>{
        var activeProfile, finalTime, initialTime, version;

        let version = phpversion();

        /**
         * @todo Remove this check when we target min PHP 7.3
         */
        if starts_with(version, "7.2") {
            //microseconds
            let finalTime = microtime(true);  
        } else {
           //nanoseconds
            let finalTime = hrtime(true);  
        }

        let activeProfile = <Item> this->activeProfile;

        activeProfile->setFinalTime(finalTime);

        let initialTime = activeProfile->getInitialTime(),
            //call by diffrent unit. (totalSeconds:seconds, initialTime & finalTime: microseconds or nanoseconds
            this->totalSeconds = this->totalSeconds + (finalTime - initialTime),
            this->allProfiles[] = activeProfile;

        if method_exists(this, "afterEndProfile") {
            this->{"afterEndProfile"}(activeProfile);
        }

        return this;
    }

I add some comments in the codes, you can check it out.
initialTime & finalTime may be microseconds or nanoseconds case different function call, and this->totalSeconds in seconds.
Also what activeProfile->getTotalElapsedSeconds() return may be microseconds or nanoseconds,and not as the function's comment say "Returns the total time in seconds spent by the profile". here is the codes:

return this->finalTime - this->initialTime;

 /**
     * Returns the total time in seconds spent by the profile
     */
    public function getTotalElapsedSeconds() -> double
    {
        return this->finalTime - this->initialTime;
    }

@Jeckerson Jeckerson added 5.0 The issues we want to solve in the 5.0 release bug A bug report status: unverified Unverified and removed need script to reproduce Script is required to reproduce the issue labels Mar 26, 2021
@Jeckerson Jeckerson added this to the 5.0.0 milestone Mar 26, 2021
@niden niden removed this from the 5.0.0 milestone Apr 8, 2021
@niden niden mentioned this issue Apr 9, 2021
5 tasks
@niden niden added status: medium Medium and removed status: unverified Unverified labels Apr 9, 2021
@niden niden mentioned this issue Apr 9, 2021
5 tasks
@niden niden linked a pull request Apr 9, 2021 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5.0 The issues we want to solve in the 5.0 release bug A bug report status: medium Medium
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants