Deutsch   English   Français   Italiano  
<vdjm2s$394jf$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!feeds.phibee-telecom.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Janis Papanagnou <janis_papanagnou+ng@hotmail.com>
Newsgroups: comp.lang.c
Subject: Re: A very slow program
Date: Wed, 2 Oct 2024 16:41:32 +0200
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <vdjm2s$394jf$1@dont-email.me>
References: <vc7nb0$7rl3$1@paganini.bofh.team>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 02 Oct 2024 16:41:32 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="3f0bfabc5ad60437ff3d02ff1010d694";
	logging-data="3445359"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+KypZ8P5W7vXA9bImcwiKH"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
 Thunderbird/45.8.0
Cancel-Lock: sha1:trLHe9NFG3o8T6OZOrf94ZOlDnw=
In-Reply-To: <vc7nb0$7rl3$1@paganini.bofh.team>
X-Enigmail-Draft-Status: N1110
X-Mozilla-News-Host: news://news.eternal-september.org
Bytes: 2897

On 16.09.2024 00:45, Student Project wrote:
> [ snip C program ]
> /*
> The result on my slow machine:
> Program takes an average of 0.018000 seconds to find 78498 primes.
> */

Note, this is the same runtime magnitude that Unix'es 'primes'
command needs to run on 1000000 numbers to create 78498 primes
(0m00.01s) [on my very old (and slow) Unix system].

Is there a point in still writing own programs for that task?
I see some point when examining performance optimizations (as
someone downthread seems to have done). For cryptography there's
certainly demands for yet faster (parallelized) algorithms - if
quantum system algorithms don't make it superfluous (lately, or
in near future). But for cryptography you'd anyway need larger
numeric domains, beyond '[long]* integer' arithmetics. (I don't
know whether the [downthread posted] C++ code was designed to
support arbitrary length arithmetics.)

Optimized algorithms of new methods alone might not be a C topic.
But given your posting name, "Student Project", I suppose you're
anyway just using it as example for learning the C language?

For ordinary users it's probably sufficient to use an existing
program; on Unix 'primes 1 1000000000' runs in about 8 seconds.
And it's checking 2^32 numbers in 50 seconds (including 'wc'
and creating output [suppressed by redirection]), generating
50847534 primes. A simple prime test of some "arbitrary large"
number runs in no time, as does factorization of numbers with
the Unix'es 'factor' program. Just a simple command line call.
That existing 'primes' program also has some limit; the man page
documents a value of 4294967295, but no error message is created
for values up to around 1.8446744*10^19 on my system.

Janis