2007-07-17:
[22:07] <midnightmonster> so that anagrams script that through various helps on the list has gotten down to 1.5 sec on my dev machine? It takes 59 (!!!) seconds to run on my production server (except when Apache times out waiting for Jetty, which appears to happen at 60 sec).[22:34] <zumbrunn> midnightmonster, can you somehow provide an example app/data in order to be able to reproduce this?[22:34] <midnightmonster> yeah--the code is super short. I'll paste it here.[22:35] <zumbrunn> don't I need the data too?[22:35] <zumbrunn> (the file you are loading)[22:35] <zumbrunn> or are you just writing the file?[22:35] <midnightmonster> yeah... it's on the web. I got it from the Code Kata site. I'll find the link[22:35] <midnightmonster> var f, w, hash, start, a;[22:35] <midnightmonster> start = (new Date()).getTime();[22:35] <midnightmonster> (f = new File('c:/temp/wordlist.txt')).open();[22:35] <midnightmonster> hash = {};[22:35] <midnightmonster> while(w = f.readln())[22:35] <midnightmonster> {[22:35] <midnightmonster> if(!hash[(key = w.toLowerCase().split('').filter(function(c){ return c>='0'; }).sort().join())]) hash[key] = [w];[22:35] <midnightmonster> else hash[key].push(w);[22:35] <midnightmonster> }[22:35] <midnightmonster> f.close();[22:35] <midnightmonster> res.contentType='text/plain';[22:35] <midnightmonster> for(a in hash) if(hash[a].length>1) res.writeln(hash[a].join(' '));[22:35] <midnightmonster> writeln('found anagrams in '+(((new Date()).getTime() - start)/1000).toFixed(3)+' seconds');[22:36] <midnightmonster> (obviously change the path in the 3rd line)[22:36] <midnightmonster> http://pragdave.pragprog.com/data/wordlist.txt[22:36] <zumbrunn> ok, thanks :-)[22:41] <midnightmonster> zum, nevermind: it was the shitty java runtime fedora core came with[22:42] <midnightmonster> I nuked it and installed Sun's 1.6.0_02[22:42] <zumbrunn> ok[22:42] <midnightmonster> Now these are my results:[22:42] <midnightmonster> found anagrams in 2.713 seconds[22:42] <midnightmonster> found anagrams in 1.783 seconds[22:42] <midnightmonster> found anagrams in 1.116 seconds[22:42] <midnightmonster> found anagrams in 1.154 seconds[22:42] <midnightmonster> found anagrams in 1.183 seconds[22:42] <zumbrunn> that's better :-)[22:42] <midnightmonster> oh, yeah[22:42] <midnightmonster> I feel *so* much better now[22:43] <zumbrunn> we'll still need to look into why helma.File is slower, though[22:44] <midnightmonster> yeah. it was still order of magnitude slower on 1.6 on my workstation[22:44] <midnightmonster> (helma and jre 1.6)[22:48] <midnightmonster> and I just tried file read only on the production server.[22:48] <midnightmonster> With File:[22:48] <midnightmonster> 0.061, 0.019, 0.023, 0.018, 0.018, 0.021, 0.017[22:48] <midnightmonster> With helma.File:[22:48] <midnightmonster> 0.526, 0.343, 0.147, 0.147, 0.142, 0.143, 0.144
In the channel now:
Logs by date: