Break the rules (or need for speed #1)

Sometimes some has to process a huge amount of data, applying stupid tests and formulas. There I was and stuck on low performance problem.

The obvious way is to implement the critical part (the stupid tests and formula in C and process the data using the C implementation only), sadly it’s often not even possible to customize php.

Having reached a point where no further optimizations were possible, I start to see what is slow inside php or what I can add to make trivial tasks faster.

One test surprised me: get the sign of a number.

So I go for a new get_sign() internal function and these results:

get_sign: 0.095184011459351
php tests: 0.21789693832397

No comment as I’m pretty sure such new functions will be rejected, keeping in mind the famous „1 line php code“ rule. What’s about (default) speed is my only anwser.

patch: http://pierre.dotgeek.org/ze2/get_sign.patch
tests: http://pierre.dotgeek.org/ze2/get_sign_test.phps

Für neue Blogupdates anmelden:


2 Gedanken zu “Break the rules (or need for speed #1)

  1. As Pierre wrote before sometimes you need functions you usually would say "no, you’ll never need this, this task can be done with just one line PHP" but later you see "Okay, now I would need it".

    We hat such a situation a few day

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.