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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:41:55+00:00 2026-06-07T17:41:55+00:00

I am profiling my code in php. Question is about next function: // returns

  • 0

I am profiling my code in php. Question is about next function:

// returns true if edge exists in the tree
protected function edgeExist( $srcNodeId, $firstToken ) {
    $result = array_key_exists( $srcNodeId, $this->edges )
              && array_key_exists( $firstToken, $this->edges[$srcNodeId]);
    return $result;
}

According to the profiler, function edgeExist consumes about 10% of running time, but function array_key_exists consumes about 0.2% of running time.
Why does function edgeExist consume so much?

  • 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-06-07T17:41:57+00:00Added an answer on June 7, 2026 at 5:41 pm

    This could be faster, try it:

    protected function edgeExist( $srcNodeId, $firstToken ) {
        return isset($this->edges[$srcNodeId][$firstToken]);
    }
    

    There is a small difference when using array_key_exists() and isset(). Look in to the manual.

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

Sidebar

Related Questions

I have a weird question. After profiling my code several times with NYTProf. I
I'm profiling some code, and cProfile reports that almost all the time is spent
We've been profiling our code recently and we've come across a few annoying hotspots.
I need some help in terms of profiling existing code in terms of execution
The SO community was right, profiling your code before you ask performance questions seems
Currently I am doing the profiling to a piece of code. During the profiling,
Here is the current code in my application: String[] ids = str.split("/"); When profiling
I am using the following code, in PHP, to get the thumbnail (from the
I use PHP and JavaScript in my project, which I entirely code with netbeans
I'm using PHP and mongodb. I've turned on system profiling on everything above 20ms,

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.