Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Perhaps I am missing something, but at least the PHP example is not the most efficient. Seems like you could easily build a nice regex with all your nouns and replacing them in the string, rather than splitting up the text and looping through each word. The code would be considerably shorter and likely quite a bit more efficient.

As for your comment on you have to load up the nouns file each file, assuming you have PHP 5.2 or later, the file will stay in memory when using APC and is reused. You can opt to extract the content and store that in memory also.

Lastly, for performance, the code could be improved as I mentioned above, but Apache is definitely not the way to go for performance. NGINX is the way to go, both are very similar, but when it comes to performance NGINX is super lightweight, fast and handles a heck of a lot more connections.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: