Date: Tue, 15 Jul 2014 00:47:54 +0200 From: Joerg Sonnenberger <joerg@britannica.bec.de> To: svn-src-all@freebsd.org Subject: Re: svn commit: r268566 - head/usr.bin/users Message-ID: <20140714224754.GA2756@britannica.bec.de> In-Reply-To: <20140714193756.GA19466@neva> References: <201407120747.s6C7lpYE020200@svn.freebsd.org> <20140712195452.N3279@besplex.bde.org> <20140714192322.GA23366@britannica.bec.de> <20140714193756.GA19466@neva>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Jul 14, 2014 at 08:37:56PM +0100, Alexander Nasonov wrote: > Joerg Sonnenberger wrote: > > On Sat, Jul 12, 2014 at 09:34:28PM +1000, Bruce Evans wrote: > > > Run time: > > > C++ sort() was twice as slow as qsort() for sorting 1 million dummy > > > users in the allocation tests. About 8 seconds instead of 4, except > > > when compiled with -g -O0 it was 15 seconds instead of 4. > > > > I find that claim strange and not reproducable. In my tests, std::sort > > tends to be significant faster than qsort. Attached is a small test > > program that for me is twice as fast for sorting integers... > > Integers are faster indeed but I'm not sure about used-defined > types like basic_string<CharT,TraitsT,AllocT>. qsort uses 3-way > comparison while std::sort always uses less_than (a<b) and !(a<b). > The compiler can optimize when a and b are integers but not when > they're user-defined types with a user-defined comparison function. The trinary vs binary partial order function only matters if you have lots of duplicate values. Joerg
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140714224754.GA2756>