Explore Programming

Simple PHP Timer

August 9, 2010

I was just trying to profile an HTML page for performance bottle-necks. I’m trying to follow a top-down approach, wherein I start from the entry script, and find the block of code that takes the biggest chunk of time before digging deeper into that chunk.

At this stage, it’s not feasible to drop in a full-blown profiling tool like xdebug because of the set-up overhead and amount of data it generates. So, I wrote a simple timing function that you can call at various points in your program to provide incremental and cumulative timing info in milliseconds. Just call this function anywhere in your code with a message and it’ll print that message to your PHP output, followed by millisecond timing information at that point. Here’s the function implementation:

Continue reading →

MySQLdb Leaks Memory

June 30, 2010

Whenever people search for a Python library for MySQL, they get directed to MySQL for Python. However, there are some nasties hidden in it. Searching for “mysql python memory leaks” results in a few links which suggest that using Unicode causes memory leaks with the library.

Today, however, I found another cause for MySQLdb memory leaks, while debugging a leaky Python daemon at work — database errors.

Use this script:

Continue reading →

Why I Program in C++

Representative image for the topic, Why I Program in C++

March 12, 2004

  • IBM’s Pervasive Computing Lab is an intelligent home with most electronic gadgets networked together. All but two gadgets run Java applications on Linux. IBM chose Java because “it’s a good way to insulate developers from the idiosyncracies of specific operating system deployments.”
  • Luxor is a XUL toolkit with “a (sic) ultra-light weight, multi-threaded web server, a portal engine and Apache Velocity as its template engine.” XUL is an XML vocabulary for assembling GUI.

The examples cited above unsettled me as they came. A significant portion of the literature on embedded systems and RTOS is devoted to making the reader understand the constraints under which embedded systems operate, viz. low computation power and available memory. Computation power in embedded systems comes at a cost premium and in gadgets having high volume sales, every cent of the price matters. Here we have IBM using Java for their pilot embedded systems to insulate the developers from OS specifics. Note that all but two systems run Linux. You need not read voluminous books to realize that one of the goals of an interactive system is to respond to user inputs as fast as possible. It is interesting to know that people are developing XUL toolkits in Java. Seems like we’ve had too much of it for our own good.

Continue reading →

<<

Programming

Tahir Hashmi