473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

How many lines of code get run when my script executes?

pbmods
5,821 Expert 4TB
Whew! Just got done writing the latest version of my template rendering engine, and it is a BEAST!

I'm very proud of it, and hopefully with my boss' permission, I will be able to open source it soon. But that's not what my question is about.

The class by itself is a little over 1500 lines of code, but I'm pretty sure that PHP actually ends up executing about 5 or 6 thousand lines of code before the first line of HTML gets output (and all in about a quarter of a second [1/8th after the first execution with Zend Optimizer!]... wow!).

Out of curiosity, though, I'd love to know exactly how many lines of code PHP is executing per execution.

Is there a tool out there that can do this? Preferably for Mac / *n?x platforms.

Thanks for your time.
Jul 17 '07 #1
6 1806
pbmods
5,821 Expert 4TB
I think I might have found something built into PHP that can do this:
http://php.net/declare

Not sure exactly how to make it do what I want it to, but we'll have some fun, I'm sure!
Aug 10 '07 #2
gregerly
192 Expert 100+
Whew! Just got done writing the latest version of my template rendering engine, and it is a BEAST!

I'm very proud of it, and hopefully with my boss' permission, I will be able to open source it soon. But that's not what my question is about.

The class by itself is a little over 1500 lines of code, but I'm pretty sure that PHP actually ends up executing about 5 or 6 thousand lines of code before the first line of HTML gets output (and all in about a quarter of a second [1/8th after the first execution with Zend Optimizer!]... wow!).

Out of curiosity, though, I'd love to know exactly how many lines of code PHP is executing per execution.

Is there a tool out there that can do this? Preferably for Mac / *n?x platforms.

Thanks for your time.
Nice work pbmods... I remember a big project I worked on when I first started programming PHP, I wrote like 600 lines without ever testing it. I was extatic when it worked the first time! I then realized how stupid that was and vowed never to do that again. Glad to hear about your successful project! Congrats!

Greg
Aug 11 '07 #3
jx2
228 100+
The class by itself is a little over 1500 lines of code, but I'm pretty sure that PHP actually ends up executing about 5 or 6 thousand lines of code before the first line of HTML gets output (and all in about a quarter of a second [1/8th after the first execution with Zend Optimizer!]... wow!).
sounds interesting :-)
but ...
What the zend optimizer is?

regards jx2
Aug 11 '07 #4
pbmods
5,821 Expert 4TB
Heya, jx2.

Zend Optimizer is a PHP extension that caches opcode and performs runtime optimizations on PHP code. The end result is that after the first execution, each of your scripts executes much more quickly.

You can find out more about this free utility here:
http://www.zend.com/products/zend_optimizer
Aug 11 '07 #5
kovik
1,044 Expert 1GB
Hehe I just wrote (and re-wrote three times) a template engine. It only handles conditional statements and looping, but that's all I need so far.

I had it output the entire process once and it chains together multiple templates, parsing and injecting and it does a lot more work than I thought it did in such a short time. Like, 3 seconds in all. Tokenization.. Parsing.. Output... 2 - 5 seconds. Yet, I have another script that takes forever just to print <div>s to the browser window. It's 1000 <div>s, but still. It's like, 3 seconds per 100 <div>s.
Aug 12 '07 #6
pbmods
5,821 Expert 4TB
Looks like something like this should work, except, what it's counting is number of low-level instructions, not necessarily lines.

Expand|Select|Wrap|Line Numbers
  1. function countLine($dump = false)
  2. {
  3.     static $lineCount = 0;
  4.  
  5.     if($dump)
  6.     {
  7.         return $lineCount;
  8.     }
  9.  
  10.     ++$lineCount;
  11. }
  12.  
  13. register_tick_function('countLine');
  14. declare(ticks = 1);
  15.  
  16. .
  17. .
  18. .
  19.  
  20. echo countLine(true), ' lines of code executed.';
  21.  
Aug 16 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Sticks | last post by:
ok... im not quite sure how to describe my problem. i have a php script that runs through my entire php site and writes the resulting output to html files. this is necessary as the nature of the...
1
by: Russ | last post by:
I've been trying to get my head around this for 3 days now and it seems like everything I try does not work for one reason or another. I built a test page using the TabStrip and MultiPage controls....
3
by: aaa | last post by:
I fail to see the connection between the code behind and the raw HTML of the ASPX page how do you get variables and functions to communicate with each other? I cannot get this to even fire:...
5
by: Paul | last post by:
Just wondering if someone could provide an example of passing a variable from the code behind to javascript in vb. I want to have one control have focus with the page loading with one condition...
5
by: Cord-Heinrich Pahlmann | last post by:
Hi, I'm wondering when php executes the code. I have a little script which takes around 10 seconds execution time. In those 10 seconds the script does a lot of mysql_queries and changes some...
3
by: ckirchho | last post by:
Hallo, my task is to establish some kind of full text file search in Javascript. The files and it's contents are fixed, the HTML/JavaScript pages lie offline on a server. As far as Javascript...
3
by: Stef Mientki | last post by:
hello, I'm trying to create a high level debugger, based on rpd2. So when the debugger enters a breakpoint, I want to display the values of all variables in the, let's say, 5 lines above the...
0
by: mag | last post by:
I have a make file that executes a perl script that takes PERL as an eval. The script executes the eval() function via an arguement to the script like this: target: script $(ARGUMENT) ...
3
by: jackson.rayne | last post by:
Hello, Another newbie question here. Let me explain my situation first. I have bought a 3rd party tool that runs a PHP script and gives me some HTML code which I can directly use in my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.