« first day (432 days earlier)      last day (4499 days later) » 

Dbz
11:00 PM
I feel bad asking- I should check the manuel
 
lol
Go read the manual on them. If you still have questions, I'll gladly answer.
 
Dbz
Okay, I understand array_diff()
 
@Dbz Btw: If you don't know how foreach works (which is pretty basic php) I wouldn't really care about the fastest way of solving your problem in general but I'd care about finding a solution that is clean and understandable to you. Just a random thought. No offence in any way or something :)
 
Dbz
Okay, I understand empty() as well.
I'll go reread that all.
@edorian, I want to learn the "fastest" way because it allows multiple people who think they know the fastest way will chip in and teach me different ways of solving the same problem AND I learn about php's efficiency
 
@edorian He wants to use it regularly on long lines (10,000+), correct, @Dbz ?
 
Dbz
11:04 PM
@LeviMorrison, you are correct.
 
Thing is: The speed differences of that will pretty much never ever matter at all and usually people that ask for the "fastest" way haven't understand what they are trying to achieve and why and doing pointless micro-optimisations.
 
Hm, another guy from kino.to got three and a half years ...
 
But as your way of getting people to talk seemed to have worked out I can't argue with the results
 
Dbz
Well @edorian, in this case I am running the operation on multiple strings of arbitrary lengths - some of which are greater than 10,000 characters. So, speed may in fact make a difference here. But, I generally try to learn as much as I can. It makes me a better programmer to know how the micro-optimizations work because at some point they may become macro-optimizations.
 
@Dbz You are overestimating the impact of your data size
10000 is nothing, I repeat nothing.
 
Dbz
11:08 PM
@LeviMorrison, I understad how that code works and it's neat. I really like it. I wouldn't have been able to create it myself without researching those functions.
 
The way more important points are finding where an application is slow and figuring out when that actually matters. micro optimisations are usually just a waste of time. The teaching value I can definitly see though :)
 
Dbz
@NikiC, this time it's nothing, but what if I have to run a similar program somewhere else where I have much larger data sizes. Then knowing optimizations will help a bottle-neck
 
Rough consensus is a term used in consensus decision-making to indicate the "sense of the group" concerning a particular matter under consideration. It has been defined as the "dominant view" of a group as determined by its chairperson. The term was first used by the Internet Engineering Task Force (IETF) in describing its procedures for working groups (WGs). The means to establish rough consensus was described by the IETF as follows: Working groups make decisions through a "rough consensus" process. IETF consensus does not require that all participants agree although this is, of cou...
 
And chances are your problem could be solved nicer on another abstraction level or with another tool than php if speed is really important :)
 
"(by rough consensus, of course)" lol
 
Dbz
11:10 PM
@edorian, true enough haha
 
@Dbz No, not really.
You are still overestimating the data ;)
People commonly do that, especially with databases
 
Dbz
I'll believe that
 
You know, a MySQL database can easily handle a selection on a table with several million rows and also using several joins. Even on high concurrency.
 
Dbz
I've never used a MySQL database before. The only time I'm thinking this algorithm would need to be optimized is if I'm going through millions of images
 
And you are talking only about a few thousand characters. Even if it were a few million there would be little difference ;)
@Dbz For your particular example: IO will take up much more time, several order of magnitude, then your algorithm itself ;) So if you can optimize your algo to be ten times faster it will still not change anything as the file IO is taking up all the time.
 
11:14 PM
Take this an an example: viper-7.com/fhu4Fq
 
@edorian I get bad gateway.
 
It's the most inefficent way I could come up with (well benchmarking it against the functions calls might show they are even slower for such a small string)
but even that doesn't take 10 milli seconds
 
Dbz
@NikiC, that's a good point
 
So it's really really uninteresting
@LeviMorrison No clue why. codeviper issue?
Works on my cli
 
bad gateway means php crashed ;)
 
11:17 PM
@edorian I benchmarked them, and strpos IS faster. I admit it might not make much of a difference. But that is interesting to me.
 
@edorian Actually it looks like a very fast way to do it.
@LeviMorrison bench local or server? I would be surprised local but server sounds plausible.
 
@LeviMorrison Depends on the amounts of hits in the string
 
@NikiC it is a server.
 
@LeviMorrison When hitting more than a certain % factor it will be slower due to the amount of function calls :P
 
@edorian I should have said that. I meant it was faster in some instances. Blanket statement fail :)
 
11:21 PM
@LeviMorrison Then everything is right. Locally it would probably be slower due to XDebug messing with your function call numbers
 
@Dbz Hoping the example discussion showed how much time you can waste thinking about problems that are non :)
 
@edorian Actually, it isn't a waste.
 
But again: For learning its amazing :)
 
Dbz
@edorian, what can I say? I'm pretty happy haha
 
On string length: 100000

strposall: 18.331748008728
getIndicesForLetter: 0.0074350833892822
strposall - getIndicesForLetter = 18.324312925339
That's 1000 iterations on each function
For 10 iterations (more realistic):
On string length: 100000

strposall: 0.18126082420349
getIndicesForLetter: 8.082389831543E-5
strposall - getIndicesForLetter = 0.18118000030518
 
Dbz
11:25 PM
Where did you run that test?
 
On my server here at work :)
 
@LeviMorrison are you in the us?
 
@edorian Unless my code is screwy (I'll post it), it is not a micro optimization if this is true. It's certainly not a bottleneck, but it is worth it.
@NikiC Yes, if you mean USA.
 
@LeviMorrison yeah ^^ Just wondered because 00:26 + work = ? So followed that you are in the us
 
@NikiC It's almost 5:00 here.
 
Dbz
11:27 PM
@LeviMorrison, I await your code =]
 
@LeviMorrison am or pm?
 
@NikiC pm
 
@LeviMorrison Well you did make 1Mio Chars out of 10k so thats where it might start to matter :)
 
On string length: 100000 with 10 iterations on each function:

strposall: 4.8960139751434
getIndicesForLetter: 0.61567711830139
strposall - getIndicesForLetter = 4.280336856842
Note that your version is the slow one :)
 
@LeviMorrison what is strposall and gitindicesforletter?
 
11:29 PM
@NikiC I'll post it in a moment.
I'm checking for stupid mistakes before I make it too public :)
 
Dbz
@LeviMorrison, can you run my version too?
function findSearchPos($string, $letter) {
    $index = strpos($string, $letter);
    if($index === false)
    	return;
    $indicies = array();
    $indicies[0] = $index;
    //print_r($indicies);
    $i = 0;
    while(($index = strpos($string, $letter, $indicies[$i]+1)) !== false)
        $indicies[++$i] = $index;
    return $indicies;
}
 
@Dbz Click the link in fron of the text, click edit, click fixed font, press enter
 
@LeviMorrison make it too public first pls
 
Dbz
@edorian, thanks
 
The numbers seem to differ too much to be true ^^
 
11:32 PM
@NikiC exactly why I'm checking
 
Dbz
I agree, there is quite a big difference
But then again, I don't really know what I'm talking about, so I'll sit and watch
 
By the way, a really pertinent way to solve the problem is $indices = array_keys(str_split($str), $chr);
Though that will undoubtedly be really slow ;)
 
@NikiC It is. I checked it early on :P
 
@LeviMorrison But at least it's pertinent :D
I like pertinent and concise solutions :)
 
Ah, I found the stupid error I was looking for.
Rerunning tests.
 
11:34 PM
@LeviMorrison I thought so ^^
 
Dbz
@NikiC, I don't know any of those functions
@LeviMorrison, is my solution included in those tests by chance?
 
My work server has error reporting turned off, so I didn't see the warning raised :) The IO was why it was so slow :)
 
Dbz
@NikiC, thanks
 
@Dbz Btw, PHP has really, really many predefined library functions. You can solve most simple tasks like this by combining one or two of them ;) But it takes quite some time to know all those functions and their various arguments :)
 
Dbz
11:38 PM
@NikiC, I can tell. It's just going to take a while to learn them all. Php is really simple though
Thankfully* I should say
 
Who comes up with these names/acronyms en.wikipedia.org/wiki/CCMP
 
@LeviMorrison So what do the new tests say?
@stevether You would have liked CMCBCMCP more?
 
STLA!
(stupid three letter acronyms)
 
@edorian by the way, is there a STUPID design pattern?
 
@NikiC Here SOLID and GRASP come to die? Like the idea
 
11:46 PM
we should think something up :D
 
S = Singleton / Static ^^
 
Singleton, Tight Coupling,
 
hm...
 
UntestedButFinished ?
 
11:49 PM
nah
 
@Dbz @NikiC @edorian My new tests. The results aren't quite what I thought they'd be: viper-7.com/0YYdhq
 
must be sthg better
 
just "untested" ?
yeah. To weak
 
@LeviMorrison But they are what I expected ;)
 
Dbz
@LeviMorrison, they're interesting though
 
11:51 PM
@NikiC Well it's accurate if nothing else.
 
@NikiC At least on my machine and on the work server, on the 'sparse' test, strpos is actually fastest.
 
P = ParsingHtmlWithRegex ? :P
 
My favorite acronym is GNU
 
@stevether PHP works the same way with the infinite expansion :P
 
@NikiC @Dbz It seems when it is more sparse, the strpos outperforms.
 
11:53 PM
@LeviMorrison btw the simple array_keys + str_split approach isn't that slow either: viper-7.com/2RREgy
 
Honestly, grab some real data and test it on that.
@NikiC Try it on sparse data.
 
@LeviMorrison too lazy
 
Dbz
Well, apparently the giant algorithm I just wrote is too slow
 
While PHP originally stood for "Personal Home Page"
interesting
 
@edorian hm...
 
11:55 PM
To bad there is no "A" in stupid
 
@edorian what would it mean?
 
Active Record? :)
 
hm, there seems nothing good for UPID
U = Untested?
Oh, you already said that ^^
 
@NikiC @Dbz see: viper-7.com/qIarWo
 
"Hurd" stands for "Hird of Unix-Replacing Daemons", and "Hird" stands for "Hurd of Interfaces Representing Depth."
 
11:58 PM
I'll be back shortly.
 
These people are just bored.
 
I'll go to bed. But i like the idea, going to pick that up tomorrow. Could be a nice addon for a SOLID talk :)
Cya guys
 
Dbz
@LeviMorrison, I like that. Mine does pretty well at the end.
 
@edorian night and me too going to sleep
 

« first day (432 days earlier)      last day (4499 days later) »