The way I see it Website development (PHP, JS, MySQL) by Damian Sromek

31Mar/120

[How to] Speed up Windows 7 boot-up time – turn off media sharing

How to find out what's using resources?

Since some time I've noticed that after logging in to Windows 7 something is doing a lot of HDD I/O operations for like 3 minutes.

This was of course making everything else running much slower. Especially running any app for the first time was taking much longer than it should.

After checking in "Performance Monitor" (standard Windows tool) I've noticed that Wmpnetwk.exe process is performing most of the HDD I/O operations.
This is part of the Windows Media Player which lets you share media through network. @see Windows media sharing

When you have a lot of media (pictures, movies) it takes long to scan for changes etc. This is what was taking so long after system start-up. I'm not using this feature anyway so I've decided to turn it off.

How to disable Windows media sharing?

  1. Run services.msc
  2. Stop and disable  "Windows Media Player Network Sharing" service

You can read this post for more details (screenshots).

3Jan/119

[How to] Run PHPUnit tests using database 10x faster

Overview

PHPUnit tests that are heavily using the database can run like 10x faster when you run the database from the RAMDisk.
It's the easiest way I know to improve the speed of the tests execution.

Problem - PHPUnit tests can run long time when they are using the database

Project I'm contributing at my work - License Statistics - uses quite a lot of unit tests.
One of the reasons is that we try to do the Test Driven Development (TDD). But this method of creating the software has some drawbacks.

Right now we have something around 1 000 tests that check around 3 000 assertions. Much of them involve database operations. That's why running all tests on Windows machine can take up to 25 minutes.

Tests on Linux machine are much faster - around 7-10 minutes but we still need to run tests under Windows environment due to fact we have to support both platforms and we have to be sure that both of them work perfectly fine.

3Jan/110

[Watch out] Zend_Date performance

Problem - Zend_Date offers small performance

I always try to use objects when I see they are giving me more flexibility than arrays or primitive types.

During my work often I have to operate on dates so I use Zend_Date quite a lot - our project is based on the Zend Framework. But recently I've run a profiler for one of the pages I created and I saw huge impact on the performance that Zend_Date had.

It did speed up development and made it easier but it also made the code much slower. Zend_Date Comparing with the plain PHP DateTime was like 5 to 10 times slower. Even Zend_Date::toString took quite large amount of CPU time.

Solution - use PHP DateTime instead of Zend_Date

Solution for that part of code was replacing the Zend_Date used in the loops (executed even couple hundred times) with DateTime. It was very simple. Also date operations like adding one day is very easy when we have DateTime object - we just need to pass a DateInterval into DateTime::add().

I'm still using Zend_Date for example as the method parameter but in code where I do many date operations I replace it with the DateTime. Thanks to that my scripts are executed much faster.

Some of DateTime features are available since PHP > 5.3 but you can easily use DateTime with older PHP doing small changes in the code.

20Dec/100

[How to] ExtJS stateful components – Ext.Panel collapsed/expanded state stored in cookies

ExtJS allows saving the state of any component that extends Ext.Component. That means that I can store/save, for example in Cookies, state of almost any GUI component made with ExtJS.

To store the state of the component so it will look the same after page reload or after going back to the same page I need to do few simple things.

// 1. Activate a State Manager using State Provider.
// The simplest is the Cookie Provider implemented by ExtJS developers
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());

// 2. Create an Component and mark it as stateful
// eg. GridPanel can save columns order etc.
var grid = new Ext.grid.GridPanel({
   ...
   stateful: true,
   stateId: 'my_grid_id_for_state_manager',
   ...
});

Now let's try to make a stateful Ext.Panel.