# PHP modules (pecl) and PHP codes (pear)

- Thread: https://externals.io/message/45895
- Original archive: https://news-web.php.net/php.internals/45895
- Started by Samuel ROZE on 2009-10-29T09:34:52+00:00
- Messages: 7
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #45895 — Samuel ROZE — 2009-10-29T09:34:52+00:00

URL: https://externals.io/message/45895#45895

Hi,

I'll have to develop a function like "parse_url", but "parse_referrer"
which provides informations about the URL (the referrer): provider,
keywords, type of search (search, cache, translation, ...), real page
url...

I don't really know how I'll do that: using a .ini file like
"get_browser" ? I think it will be too complicated and difficult to
build.. but maybe it is a good idea ? Or create it in C as an
extension...

I want to know if compiled extensions in C are really faster than an PHP
function ?

Thanks !
Samuel.

---

## #45896 — Ferenc Kovacs — 2009-10-29T09:49:45+00:00

URL: https://externals.io/message/45895#45896 · In reply to: #45895

> Hi,
>
> I'll have to develop a function like "parse_url", but "parse_referrer"
> which provides informations about the URL (the referrer): provider,
> keywords, type of search (search, cache, translation, ...), real page
> url...
>
> I don't really know how I'll do that: using a .ini file like
> "get_browser" ? I think it will be too complicated and difficult to
> build.. but maybe it is a good idea ? Or create it in C as an
> extension...
>
> I want to know if compiled extensions in C are really faster than an PHP
> function ?
>
> Thanks !
> Samuel.
>
>
> --
> 
> 
>
>

As fas as I know, yes obviously faster, but I think that in your case
it doesn't worth the extra time to build this functionality in C,
because it is mostly regex based string parser, so the overall
overhead is minimal.

Tyrael

---

## #45897 — Alexey Zakhlestin — 2009-10-29T11:03:13+00:00

URL: https://externals.io/message/45895#45897 · In reply to: #45895

> Hi,
>
> I'll have to develop a function like "parse_url", but "parse_referrer"
> which provides informations about the URL (the referrer): provider,
> keywords, type of search (search, cache, translation, ...), real page
> url...
>
> I don't really know how I'll do that: using a .ini file like
> "get_browser" ? I think it will be too complicated and difficult to
> build.. but maybe it is a good idea ? Or create it in C as an
> extension...
>
> I want to know if compiled extensions in C are really faster than an  
> PHP
> function ?

Usually, it is a good idea to write it in PHP at first and then port  
to C, if performance is poor

---

## #45898 — Samuel ROZE — 2009-10-29T15:58:37+00:00

URL: https://externals.io/message/45895#45898 · In reply to: #45897

Le jeudi 29 octobre 2009 à 14:03 +0300, Alexey Zakhlestin a écrit :
> Usually, it is a good idea to write it in PHP at first and then port  
> to C, if performance is poor

But I lose some time !

---

## #45899 — Patrick ALLAERT — 2009-10-29T16:37:05+00:00

URL: https://externals.io/message/45895#45899 · In reply to: #45898

2009/10/29 Samuel ROZE <samuel.roze@gmail.com>:
> Le jeudi 29 octobre 2009 à 14:03 +0300, Alexey Zakhlestin a écrit :
> > […]
>
> But I lose some time !

(Reposting with ML included.)

Yes, but as far as a PHP extension may take hundreds time to develop
than a PHP function.
If the PHP version is fast enough, you will win a huge amount of time,
if not, you will only lose less than 1% of the overall dev time.
The computation is quite easy.

What is your reqs/second target ?

--
Patrick Allaert
---
http://code.google.com/p/peclapm/ - Alternative PHP Monitor

---

## #45900 — Samuel ROZE — 2009-10-29T16:58:55+00:00

URL: https://externals.io/message/45895#45900

Le jeudi 29 octobre 2009 à 17:35 +0100, Patrick ALLAERT a écrit :
> 2009/10/29 Samuel ROZE <samuel.roze@gmail.com>:
> > […]
> 
> Yes, but as far as a PHP extension may take hundreds time to develop
> than a PHP function.
> If the PHP version is fast enough, you will win a huge amount of time,
> if not, you will only lose less than 1% of the overall dev time.
> The computation is quite easy.
> 
> What is your reqs/second target ?

---

## #45901 — Samuel ROZE — 2009-10-29T17:00:06+00:00

URL: https://externals.io/message/45895#45901 · In reply to: #45899

Le jeudi 29 octobre 2009 à 17:37 +0100, Patrick ALLAERT a écrit :
> Yes, but as far as a PHP extension may take hundreds time to develop
> than a PHP function.
> If the PHP version is fast enough, you will win a huge amount of time,
> if not, you will only lose less than 1% of the overall dev time.
> The computation is quite easy.

You're right...

> What is your reqs/second target ?

I want that my "parse_referer" function act in 1 ms maximum, that's the
problem. ;-)
