Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Ian Collins Newsgroups: comp.lang.c Subject: Re: So here's a fun challenge Date: Sun, 3 Nov 2019 18:02:43 +1300 Lines: 46 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: individual.net kIO0saj6CrSCaa/EetETSQCQQ4/ne6QvrjIldB1j0CIjSIw73o Cancel-Lock: sha1:9BL+lRmWvdcp6DA9Yg9jk/cjd3U= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 In-Reply-To: Content-Language: en-US Xref: csiph.com comp.lang.c:147526 On 03/11/2019 17:18, DFS wrote: > On 11/2/2019 9:35 PM, Ian Collins wrote: >> ZZZzN3DyoJU9hOy >> ZZZZhpliD >> ZzzzgdAwKww >> zzZZ4waPKAofj >> ZzZYshGXMOzI >> zZzyp0NY0 >> zZzyo7v3 >> ZzzYLx3l2Nmnc973 >> zzZydYrs3quxF >> ZzZy6FpMdt1Zw >> >> real    0m4.744s > > > Unbelievably quick. Nearly 10x faster than mine. I do have a senior > citizen processor (i5-750@2.67GHz). > > > But I see you didn't do a case-insensitive sort. > > > ZZZzN3DyoJU9hOy > > ZZZZhpliD > > > 3/4 of the proc time in my code is qsorting, which does untold > strcasecmp's - that's where the slowdown is. > That's odd - the other are in order - Ah! The order of the tail is reversed ZZZzN3DyoJU9hOy is the last entry. Your C version (modulo the windows stuff) gives: 1.4832s to create 10000000 random string elements (+ add dupes) qsorting... 4.8799s program ran in 7.0736s seconds So removing dupes appears to be a hot-spot. -- Ian.