help please

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: help please

Post by superdezign »

Being an interpreted language, bitwise operations shouldn't have much of an advantage in PHP.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: help please

Post by jackpf »

margaaa wrote:lol no! my course was (or is) audiovisual and multimedia. but what i really want is audiovisual, but this discipline was obligatory, and i couldn´t go to the classes.

thank you soooo much :)
Oh right...that's fair enough I guess. You have my apologies. But go to class next time :P
Mirge wrote:Hope you're prepared to explain the code if you have to then lol
What do you mean? You want to know how the code I posted works?
ricehigh wrote:I found that bitwise comparison was sligtly faster than modulo operations
How weird, my results were the other way around. But yeah, I guess since there's such a tiny margin, it can go either way...
superdezign wrote:Being an interpreted language, bitwise operations shouldn't have much of an advantage in PHP.
Sorry for my ignorance...but how would that make a difference? :)
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: help please

Post by superdezign »

jackpf wrote:
superdezign wrote:Being an interpreted language, bitwise operations shouldn't have much of an advantage in PHP.
Sorry for my ignorance...but how would that make a difference? :)
That's the point. It shouldn't. I'm not saying that bitwise operations are at a disadvantage, just that they are not at an advantage. All operations are still at the mercy of the interpreter.
User avatar
Mirge
Forum Contributor
Posts: 298
Joined: Thu Sep 03, 2009 11:39 pm

Re: help please

Post by Mirge »

jackpf wrote:
Mirge wrote:Hope you're prepared to explain the code if you have to then lol
What do you mean? You want to know how the code I posted works?
Was referring to OP lol

I didn't see you post any code in this thread?
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: help please

Post by jackpf »

superdezign wrote:
jackpf wrote:
superdezign wrote:Being an interpreted language, bitwise operations shouldn't have much of an advantage in PHP.
Sorry for my ignorance...but how would that make a difference? :)
That's the point. It shouldn't. I'm not saying that bitwise operations are at a disadvantage, just that they are not at an advantage. All operations are still at the mercy of the interpreter.
Ahh I get you now. But surely PHP has to perform these operations in C? So...whatever's faster in C would be faster in PHP surely?
Mirge wrote:
jackpf wrote:
Mirge wrote:Was referring to OP lol

I didn't see you post any code in this thread?
Ha. Yeah, that makes more sense :P

And the code I posted two posts above your last!!!
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: help please

Post by superdezign »

jackpf wrote:Ahh I get you now. But surely PHP has to perform these operations in C? So...whatever's faster in C would be faster in PHP surely?
Surely. Just marginally. :3

Then again, I don't know how the interpreter works. For all we know, it chokes on the ampersand token. :p
User avatar
Mirge
Forum Contributor
Posts: 298
Joined: Thu Sep 03, 2009 11:39 pm

Re: help please

Post by Mirge »

jackpf wrote:And the code I posted two posts above your last!!!
Oh lol I was looking for code that was written for the OP
margaaa
Forum Newbie
Posts: 4
Joined: Tue Sep 15, 2009 11:16 am

Re: help please

Post by margaaa »

Mirge wrote:Hope you're prepared to explain the code if you have to then lol
im not, but i will do my best to understand it! :)
peterjwest
Forum Commoner
Posts: 63
Joined: Tue Aug 04, 2009 1:06 pm

Re: help please

Post by peterjwest »

With small to medium performance differences, you'll usually be better choosing the more readable/understandable option. Most PHP programmers aren't too practiced with bitwise operations, so modulus would be clearer.

Also you really shouldn't be optimising arbitrarily. Use a profiler and optimise whatever takes the most time. Bitwise or modulus operations are unlikely to be the bottleneck.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: help please

Post by jackpf »

Yeah, it'll make virtually no difference. Still, it's interesting to see which is faster :D
Post Reply