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 1029403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:32:21+00:00 2026-05-16T12:32:21+00:00

I have done some profiling on a site and found that strtolower calls took

  • 0

I have done some profiling on a site and found that strtolower calls took unexpectedly long time.

The context is


function __autoload($class_name) {  
  require_once('app/model/' . strtolower($class_name) . '.php');  
}

And the result is
_0.0092 -> ___autoload() C:\xxx\config.php:0_
0.0093 -> strtolower() C:\xxx\config.php:77
0.0101 -> require-once(C:\xxx.php) C:\xxx\config.php:77
I’ve seen this on several places in the trace file.

I then tried the function in the following context


for($i=0;$i<100;$i++) {  
  strtolower('SomeStRIng' . $i)  
}

And the result was
0.0026 -> strtolower() C:\xxx\index.php:53
0.0027 -> strtolower() C:\xxx\index.php:53
0.0027 -> strtolower() C:\xxx\index.php:53
0.0027 -> strtolower() C:\xxx\index.php:53

There is a notable difference between the two. It’s no biggie overall of course but I’m still confused.

  • 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. Editorial Team
    Editorial Team
    2026-05-16T12:32:22+00:00Added an answer on May 16, 2026 at 12:32 pm

    You’re running far too small tests, on far too little data. You’ll never get consistent data, as other system factors (like CPU speed/load) will take a far greater toll.

    Your first test is disk-bound. Lowering the case of a (hopefully reasonably) short string is essentially instantaneous, or at least measured in microseconds. Hitting the disk to locate/load/parse a file will take on the order of milliseconds. You’re trying to detect a difference in something where the part you’re not concerned about takes 1000 times longer. ie: the strtolower overhead is a rounding error.

    Your second test, while being purely cpu/memory bound, is also too short to be practical. You can’t be sure that doing 100 string concatenations (and associated memory allocation) won’t overwhelm the actual lowercasing. A better test would be to prebuild a series of mix-case strings (a few hundred or thousand of them), then loop over that array repeatedly and strtolower in seuqnce. That way you’ve eliminated as much overhead/irrelevant code path as possible, and should hopefully get more consistent data.

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

Sidebar

Related Questions

I've done some research into server push with javascript and have found the general
I have done some searches looking for information about how to do logging with
I've done some Python but have just now starting to use Ruby I could
Traditionally, when we use SQL string to done some work, we have to close
Has anyone done this / have some example code?
I have done a bit of research into this and it seems that the
I have a Java Applet that I'm making some edits to and am running
I have a script that appends some rows to a table. One of the
I looking for jquery validator plugin. I have done lot of searches, some plugins
Providing that I have the following on: TeamGamesDao Class: public function listOfTeams() { $select

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.