Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 129173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:45:02+00:00 2026-05-11T05:45:02+00:00

PHP must track the amount of CPU time a particular script has used in

  • 0

PHP must track the amount of CPU time a particular script has used in order to enforce the max_execution_time limit.

Is there a way to get access to this inside of the script? I’d like to include some logging with my tests about how much CPU was burnt in the actual PHP (the time is not incremented when the script is sitting and waiting for the database).

I am using a Linux box.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T05:45:02+00:00Added an answer on May 11, 2026 at 5:45 am

    On unixoid systems (and in php 7+ on Windows as well), you can use getrusage, like:

    // Script start $rustart = getrusage();  // Code ...  // Script end function rutime($ru, $rus, $index) {     return ($ru['ru_$index.tv_sec']*1000 + intval($ru['ru_$index.tv_usec']/1000))      -  ($rus['ru_$index.tv_sec']*1000 + intval($rus['ru_$index.tv_usec']/1000)); }  $ru = getrusage(); echo 'This process used ' . rutime($ru, $rustart, 'utime') .     ' ms for its computations\n'; echo 'It spent ' . rutime($ru, $rustart, 'stime') .     ' ms in system calls\n'; 

    Note that you don’t need to calculate a difference if you are spawning a php instance for every test.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built a class in PHP and I must declare a class variable
As far as know, I must be careful with PHP, and I think Javascript.
Here is my try: @header(Content-type: text/html; charset=utf-8); @header(Location:/index.php); @header(Cache-Control: no-cache, must-revalidate); // HTTP/1.1 @header(Expires:
PHP has a great function called htmlspecialcharacters() where you pass it a string and
PHP treats all arrays as associative, so there aren't any built in functions. Can
PHP has a number of opcode caches, which as i understand it are scripts
I only need to do this for one file (uptime.php) and it must be
In PHP, I must require_once() the classes of the objects I want to put
I have created a user registration form using PHP, a password must be entered
I have a php/action.php. That script creats a file in the folder ../data/myfile.kml. After

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.