Article View: pl.comp.lang.java
Article #141804Re: Szybkość Javy wg Horstmanna a testy...
From: Abece
Date: Mon, 20 Oct 2008 20:33
Date: Mon, 20 Oct 2008 20:33
61 lines
2839 bytes
2839 bytes
Palcem pokaż:
"
#include <bitset>
#include <iostream>
#include <ctime>
using namespace std;
int main() {
const int n=2000000;
clock_t cstart = clock();
bitset<n+1> b;
int count = 0;
int i;
for (i=2;i<=n;i++)
{
b.set(i);
}
i = 2;
while (i*i<=n)
{
if (b.test(i))
{
count++;
int k=2*i;
while (k<=n)
{
b.reset(k);
k = k + 1;
}
}
i++;
}
while (i<=n)
{
if (b.test(i))
{
count++;
}
i++;
}
clock_t cend = clock();
double millis = 1000.0 * (cend - cstart) / CLOCKS_PER_SEC;
cout << "Ilosc: " << count << endl << millis << " ms.";
return 0;
}
"
Reszta ciach bo bzdurzysz. Gdybym nie poprawiał kodu, to bym dalej w to
nie brnął.
O porównywaniu... Celowo podałem owe 30ms z Durona, bo jakbyś porównał
do swoich javowych 15, to by ci wyszło, że owa java jest wolniejsza...
Ale widać matematyka z klas 1-4 szkoły podstawowej nie była twoja mocną
stroną, prawda?
Technical Details
Message-ID:
<gdiq18$nrg$1@atlantis.news.neostrada.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!newsfeed.neostrada.pl!atlantis.news.neostrada.pl!news.neostrada.pl!not-for-mailReferences:
<gdg318$g5g$1@nemesis.news.neostrada.pl> <df635ef9-4a3f-4915-be18-d2dcf7f09b9f@t18g2000prt.googlegroups.com> <24769ac6-ecbd-492d-b655-68805d8fde86@g25g2000prf.googlegroups.com> <gdi32o$ea6$5@inews.gazeta.pl> <ae5fb5c3-6e37-48db-b305-6d251b347842@o40g2000prn.googlegroups.com> <gdi45f$ohu$1@inews.gazeta.pl> <ed72be02-c2b9-469d-a6b4-f53f5d7eda3a@w1g2000prk.googlegroups.com> <gdi51u$slu$1@inews.gazeta.pl> <248a2f73-1b18-47d4-83cf-5bd9899b37b4@i20g2000prf.googlegroups.com> <gdi736$8me$3@inews.gazeta.pl> <ea528cd6-ddb9-4f02-bd8d-813de51b4133@g17g2000prg.googlegroups.com> <gdimls$fpn$1@atlantis.news.neostrada.pl> <26ba6ecf-b028-4c46-b9c1-9238ed508cdd@v13g2000pro.googlegroups.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!newsfeed.neostrada.pl!atlantis.news.neostrada.pl!news.neostrada.pl!not-for-mail From: Abece <abece.inaczej@abece.pl> Newsgroups: pl.comp.lang.java Subject: Re: Szybkość Javy wg Horstmanna a testy... Date: Mon, 20 Oct 2008 22:33:04 +0200 Organization: TP - http://www.tp.pl/ Lines: 61 Message-ID: <gdiq18$nrg$1@atlantis.news.neostrada.pl> References: <gdg318$g5g$1@nemesis.news.neostrada.pl> <df635ef9-4a3f-4915-be18-d2dcf7f09b9f@t18g2000prt.googlegroups.com> <24769ac6-ecbd-492d-b655-68805d8fde86@g25g2000prf.googlegroups.com> <gdi32o$ea6$5@inews.gazeta.pl> <ae5fb5c3-6e37-48db-b305-6d251b347842@o40g2000prn.googlegroups.com> <gdi45f$ohu$1@inews.gazeta.pl> <ed72be02-c2b9-469d-a6b4-f53f5d7eda3a@w1g2000prk.googlegroups.com> <gdi51u$slu$1@inews.gazeta.pl> <248a2f73-1b18-47d4-83cf-5bd9899b37b4@i20g2000prf.googlegroups.com> <gdi736$8me$3@inews.gazeta.pl> <ea528cd6-ddb9-4f02-bd8d-813de51b4133@g17g2000prg.googlegroups.com> <gdimls$fpn$1@atlantis.news.neostrada.pl> <26ba6ecf-b028-4c46-b9c1-9238ed508cdd@v13g2000pro.googlegroups.com> NNTP-Posting-Host: dok216.neoplus.adsl.tpnet.pl Mime-Version: 1.0 X-Trace: atlantis.news.neostrada.pl 1224534888 24432 83.24.118.216 (20 Oct 2008 20:34:48 GMT) X-Complaints-To: usenet@news.neostrada.pl NNTP-Posting-Date: Mon, 20 Oct 2008 20:34:48 +0000 (UTC) User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) In-Reply-To: <26ba6ecf-b028-4c46-b9c1-9238ed508cdd@v13g2000pro.googlegroups.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit