0

I want to calculate the time complexity of some code I have written that calls built-in PHP functions such as substr_count(), trim() etc. Because I didn't write these functions myself I don't know the complexity of them so I can't calculate the complexity of my own code as a result. Is there a way that you can either:

  • Retrieve the code for the built-in methods
  • Retrieve the complexcity for the built-in methods

Or is the only way of doing the calculation to run the code through a tool that calculates the complexity for me?

I had a look at this page which didn't help too much

Community
  • 1
  • 1
user1849060
  • 621
  • 3
  • 10
  • 20
  • 6
    Why not simply look at the [PHP source code](https://github.com/php/php-src), it is publicly accessible – Mark Baker Mar 28 '14 at 19:21
  • 2
    Sure, you have access to the code. [There's even a GitHub mirror for it](https://github.com/php/php-src) so you can browse though it within the comfort of your browser. I'm not aware of any project stating time complexity for PHP functions, though. – Carsten Mar 28 '14 at 19:21
  • I've used a system called appdynamics (http://www.appdynamics.com/products/application-performance-monitoring) on larger projects at my work, which provides reports for how long individual methods and classes take during calls to scripts and websites, but... it's pretty expensive (like 3k per server per year) so probably only ideal if this is a high budget project which will be used by millions of users and etc. I don't know of any other way to get the time of every aspect of a project that's free or open source or etc, outside of writing custom code to do this for you. – skrilled Mar 28 '14 at 19:23
  • @Carsten I can work out the complexity on my own if needs be (and if it's feasible of course). Thanks for directing me to this page. Any way that you can locate individual methods/functions though? – user1849060 Mar 28 '14 at 19:24
  • Clone the repo, use your favorite text search tool. – Sammitch Mar 28 '14 at 20:11
  • Possible duplicate of [List of Big-O for PHP functions](http://stackoverflow.com/questions/2473989/list-of-big-o-for-php-functions) – larrylampco Feb 10 '16 at 05:04

0 Answers0