laplace's demon

Programming

Zend Framework 2 comparison

by on Jan.19, 2012, under php, Uncategorized

I’ve been using Zend Framework 1.x for quite a long time. It is a stable framework with a lot of features. But I always have some performance issues in terms of memory/cpu usage and page load time. I have looked at the new version of Zend Framework which is under active development. As my first impressions, I have astonished by their new design. Removing require_once statements, using namespaces and lazy loading of components should boost the performance drastically. In addition, the new module system will be very flexible especially for 3rd party component developers.

To see it in action, I have decided to do a quick benchmark. I have used the zf2 skeleton application, and my current zend framework 1.11 setting which I use in any of my PHP projects. The comparison is totally subjective and the aim is to have an overall impression.

I have used the apache benchmarking tool. The number of requests are 100 and the concurrency level is 5.
ab -c 5 -n 100 http://myUrl

Here are the results

Zend Framework 2

Server Software: Apache/2.2.20
Server Hostname: localhost
Server Port: 80

Document Path: /zf2-sample/public
Document Length: 351 bytes

Concurrency Level: 5
Time taken for tests: 0.214 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Non-2xx responses: 100
Total transferred: 61900 bytes
HTML transferred: 35100 bytes
Requests per second: 466.58 [#/sec] (mean)
Time per request: 10.716 [ms] (mean)
Time per request: 2.143 [ms] (mean, across all concurrent requests)
Transfer rate: 282.04 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 10 6.3 11 33
Processing: 0 1 2.6 0 15
Waiting: 0 0 2.6 0 15
Total: 1 11 6.1 11 33

Percentage of the requests served within a certain time (ms)
50% 11
66% 12
75% 13
80% 14
90% 16
95% 23
98% 32
99% 33
100% 33 (longest request)

Zend Framework 1.11


Server Software: Apache/2.2.20
Server Hostname: localhost
Server Port: 80

Document Path: /ad
Document Length: 336 bytes

Concurrency Level: 5
Time taken for tests: 0.410 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Non-2xx responses: 100
Total transferred: 58900 bytes
HTML transferred: 33600 bytes
Requests per second: 243.98 [#/sec] (mean)
Time per request: 20.494 [ms] (mean)
Time per request: 4.099 [ms] (mean, across all concurrent requests)
Transfer rate: 140.33 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 20 14.7 16 53
Processing: 0 1 3.6 0 28
Waiting: 0 1 3.5 0 28
Total: 1 20 14.4 17 53

Percentage of the requests served within a certain time (ms)
50% 17
66% 29
75% 33
80% 34
90% 40
95% 46
98% 51
99% 53
100% 53 (longest request)

Conclusion: New version of Zend Framework is nearly double times faster that the current version.

Leave a Comment : more...

Unit Testing Asynchronous Operations with OCTest

by on Sep.21, 2011, under Programming

I have experienced problems while I write the unit tests for a RESTLike web service client. The client class is basically a wrapper around NSURLConnection which asynchronously fetch/download data from a server. Unit tests are synchronously operations and will not work in this context.

The test case is the following: connect to a server via its URL and fetches some data from it. I have used a loop while the downloading operation continues to force the test method to wait for the connection class to finish its job. Following is the test case method:

- (void)testConnection {
    // the custom strategy class to encapsulate the behavior of the rest client
    WSRestClientDefaultStrategy* strategy = [[WSRestClientDefaultStrategy alloc] init];
    // create the rest client under testing
    WSRestClient* client = [WSRestClient restClientWithStrategy:strategy withMethodName:@"anymethod" andParams:nil andHttpMethod:@"GET"];
    [client execute];
    [strategy release];

    // this is a workaround in order to test async requests
    NSRunLoop* runLoop = [NSRunLoop currentRunLoop];

    // wait while the connection class does its job
    while ([client loading] && [runLoop runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]);
}

Please note that the unit test normally should not fetch any data from any external service. Please consider to use mock classes to reduce the dependency. You can use a framework like OSMock for creating the mock classes

Leave a Comment :, more...

a netbeans bug on jax-rpc

by on Apr.19, 2011, under Programming

I have tried to write a rpc web service client in java using a wsdl file on netbeans, but a ittle bug drives me crazy. If you come across the following error during the compilation, then the following solution might save your time.

taskdef class com.sun.xml.rpc.tools.ant.Wscompile cannot be found

open up /nbproject/project.properties
Change:

wscompile.classpath=${wscompile.tools.classpath}:${j2ee.platform.wscompile.classpath}

To:

wscompile.classpath=${wscompile.tools.classpath}:${j2ee.platform.wscompile.classpath}:${javac.classpath}

woila

Leave a Comment more...

rest vs rpc

by on Apr.01, 2011, under Programming

Well, i came across a great comparison article and i want to share it. Well this is because my bookmarking system sucks. So when i need to save a document, i post it in my blog. Yeah it sucks.

http://md314159265.wordpress.com/2006/10/30/comparison-of-rest-vs-xml-rpc/

1 Comment more...

Getting PHP headers without apache mod headers

by on Feb.08, 2011, under php, Programming

It sometimes happen. You are in a restricted environment -like a shared hosting- and somehow you want to reach the custom headers without enabling the apache module “mod_headers”. Than following little function will do your job.

function getHeaders()
    {
        $headers = array();
        foreach ($_SERVER as $k => $v)
        {
            if (substr($k, 0, 5) == "HTTP_")
            {
                $k = str_replace('_', ' ', substr($k, 5));
                $k = str_replace(' ', '_', strtolower($k));
                $headers[$k] = $v;
            }
        }
        return $headers;
    }

P.S. If you have the possibility to use the mod_headers, than you’re free to use apache_get_headers() function.

Leave a Comment more...

Mac Maintenance Scripts

by on Jan.03, 2011, under mac

Mac OSX schedules and runs some kind of maintenance scripts. Those scripts only removes some invisible system log files that is not a big deal. But the thing is, it schedules the scripts at 3:30 am of the day, week or month. But off course you can manually run them via following command

sudo periodic daily weekly monthly

It’s ok not to see a output when you run the command.

Leave a Comment more...

Think beyond DB

by on Nov.12, 2010, under php, Programming, Tech

I found a good presentation by the project lead of Zend Framework. He explains the data persistance and why good OO programming instead of refactoring is saves a lot of time.

Leave a Comment :, more...

How to re-locate SVN repository

by on Nov.01, 2010, under linux, Programming

Recently our local svn server location is changed. We use ip-address rather than a domain name for the svn server, so we needed to change the repository location in our working copies.

To change the svn location, use the following syntax:


svn switch --relocate svn://oldhostname/myrepository svn://newhostname/myrepository

Edit: I’m so lost that i forgot to exclude the username and password variables from the code above :)

Leave a Comment : more...

Sroups is coming out

by on Aug.27, 2010, under Programming, Tech, Work

Yeah it’s coming soon. We’re developing a social network application at OyunStudyosu where you can turn your website into a virtual world. In sroups (which is a flash application), users will step into a virtual isometric world and interact with other people who visit the website at the same time.

The idea, somehow, reminds me the matrix movie which is by far the most influenced movie for a programmer. In matrix, people log into the virtual world called matrix (not using flash application though :) ), and interact with other “virtual” people. Everything is software, everything is obkject in that world but the experience is real. I really wish that I have a world like that. Sroups gives us an opportunity to use the matrix (imo). But it’s a pity that we can’t bind our body to that world physically.

Well, I should mention that there are plenty of virtual worlds around, like warcraft (which is awesome), but the main difference is, sroups is like a simulation of the containig website, not a game, not a fantasy. At least it should. Of course the project is in (closed) beta now and it’s too primitive to make an analysis.

But yeah, for me, the idea is very excited.

Btw, I’ve decided to write my posts in english from now on. Will explain the reasons later.

Leave a Comment :, more...

Mac’de port kullanımını görmek

by on Jun.09, 2010, under mac, Programming

için güzide bir komut var. işte şu:

sudo lsof -i -P

Ubuntu için de şu kullanışlı

sudo netstat -lntp
Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...