Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="UTF-8" Message-ID: <1481633.v4UOFUmKin@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Sat, 14 Sep 2013 12:10:56 +0200 User-Agent: KNode/4.10.5 Content-Transfer-Encoding: 8Bit X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. <3251928.WeJvBNZfad@PointedEars.de> <10475868.RPHzNtd8jb@PointedEars.de> <7523620.37GnReVopu@PointedEars.de> <0.966398b0a330b8f4cff2.20130914015540BST.87six8kyr7.fsf@bsb.me.uk> <26040281.ttGrEoHtI1@PointedEars.de> <0.7296b1b07acee9593ab0.20130914061641BST.87fvt8kmo6.fsf@bsb.me.uk> MIME-Version: 1.0 Lines: 55 NNTP-Posting-Date: 14 Sep 2013 12:10:57 CEST NNTP-Posting-Host: 6b6b03e6.newsspool4.arcor-online.net X-Trace: DXC=Xn6@Kk?::fNgj[ZPFj7ehO4IUK Thomas 'PointedEars' Lahn writes: >> Ben Bacarisse wrote: >>> Thomas 'PointedEars' Lahn writes: >>>> The algorithm differs in that properties of the object referred to by >>>> “not_prime” (formerly: “comp”) are removed as they are no longer >>>> needed. This *might* decrease the memory footprint (thus increase the >>>> memory- efficiency), but it adds another step (thus decreases the >>>> runtime- efficiency). >>> You say above that this code is an optimised version of mine, but then >>> you say it *might* decrease memory footprint, >> I said the *deletion* might decrease the memory footprint. > > Yes, I understood that. My point is that you cite it as a potential > benefit. If a program uses less memory than another while doing the same thing or even more than the latter, that is a benefit. >>> but that all the deleting decreases the runtime-efficiency. In what >>> sense has it been optimised? >> >> - it can store primes up to 2⁵³−1 (an Array instance can only hold 2³²−1 >> elements) >> - reduced memory usage (Object instead of Array) >> - potentially faster (no extra Array.prototype.push() calls) >> - post-increment replaced with pre-increment (maybe faster) > > But it could also be slower and use exactly the same amount of memory. > In fact that is the case in both engines I tested. As posted, your > "optimised" version did not finish in two minutes when run under nodejs, > and was about 4 to 5 times slower than mine in rhino. That does not > match what I think of as optimised code. If you think of optimization only in terms of runtime-efficiency, you are correct. >>> On two test engines (rhino and nodejs) the deleting has a huge impact on >>> the run time (a factor of four in rhino and way more in nodejs -- so >>> much so I killed it before getting a time). >> >> Thanks. > > For testing, or showing that deleting elements is slow? Both. Please trim your quotes to the relevant parts. -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.