Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: ram@zedat.fu-berlin.de (Stefan Ram) Newsgroups: comp.os.linux.misc Subject: Re: Simple Programming Challenge Date: 13 Nov 2025 13:24:22 GMT Organization: Stefan Ram Lines: 25 Expires: 1 Jun 2026 11:59:58 GMT Message-ID: References: <18774b74533f13ac$14097$3668313$802601b3@news.usenetexpress.com> <5L1RQ.59910$3VN7.27458@fx41.iad> <18774fee1aa33cb0$22907$3467166$802601b3@news.usenetexpress.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de YpeKJQN3UIHq5IjEqHgH9gT6zFjt1P2Bq4OxBUwY+mIpnW Cancel-Lock: sha1:VYwCgqf32lUUf11Q8ooqPObLMD4= sha256:WQ4M8SDRcKb0UuVgZLiOgB9vu9/BqsOMZVLLj3g7/0I= X-Copyright: (C) Copyright 2025 Stefan Ram. All rights reserved. Distribution through any means other than regular usenet channels is forbidden. It is forbidden to publish this article in the Web, to change URIs of this article into links, and to transfer the body without this notice, but quotations of parts in other Usenet posts are allowed. X-No-Archive: Yes Archive: no X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some services to mirror the article in the web. But the article may be kept on a Usenet archive server with only NNTP access. X-No-Html: yes Content-Language: en Xref: csiph.com comp.os.linux.misc:77475 Joe Fantastic wrote or quoted: >Too many additions. I know that terminal output is slow, so I just wrote to memory and have one single terminal output at the end. However, for my benchmark I used ">/dev/nul" and found out that: - My program is much slower than the C programs shown here. - The most dramatic speed-up resulted from using C instead of C++. (So the "++" in "C++" actually constitute the "too many additions".) - The "strength reduction" avoiding "%" also slowed down my program a bit. - But even after I ported my program to C and improved it a bit, the programs that just call "printf" multiple times are still faster. - measured using: /usr/bin/time -f "%U" bash -c 'for i in {1..1000}; do ./a.out > /dev/null 2>&1; done' .