I get around 0.008s on my app, but on the one I sent in I get around 0.01s...
Printable View
I get around 0.008s on my app, but on the one I sent in I get around 0.01s...
I did it originally like that and thought it would be classed as cheating because the system hadnt really worked it out :D
0.2 compiler duron 1400 or so :D
0.12 if i compile with advanced debugging options set :D
Yeah... Im down to 0.0074 with the advanced options on.
Woohoo! I finally found out a superb routine! 0,03 ms compiled and 1,1 ms in IDE for 1000 primes. It gives correct results too! :D
Gotta download a better timing code, I had to use GetTickCount and loop the code 10000 times to get it accurate... worked out the whole thing on my laptop. I love modem :)
Edit 51 ms to find 41538 primes (all primes below 500000).
Get the sTime module... It's pretty accurate.
What machine are you running on?
Athlon XP-M 2400+ @ 1800 MHz
Btw, the results went down when I switched to sTime. Happiness.
I use 2 as a hard coded prime.Quote:
Originally posted by BodwadUK
Can we make assumptions e.g do we HAVE to calculate by checking all numbers or can we skip them if mathmatically they cant be prime numbers :)
I've heard someone say they need the first 2 primes for their progie to work.Quote:
a comment in my progie
'Also, since 1 is not a prime, and since the only whole positive integer below 2 is 1, then
'2 is the first prime
Some people, I expect, are sequencing with 6n Plus or Minus 1, which is an inherent usage of 2 and 3 as primes.
Obviously, the more primes you hard code, the faster your code will run.
Perhaps a point system should be applied, allowing you usage of n primes hard coded, but it lowers your overall for every one you use.
-Just a thought
-Lou
As for the hardcoded primes thing we decided you could hardcode as many as you wanted but be warned you will loose points for "sexiness" of the algo if you go over the top ;).
BTW Bodwad are you not entering your code? Just cos you're keep posting it publicly :confused:.
Is it still finishing on the 25th?
Dont we just post it here :confused:
:rolleyes:
I can only hope you are joking :lol:.
Quote:
Originally posted by BodwadUK
Is it still finishing on the 25th?
Dont we just post it here :confused:
you have to post your code in the contest entries forum :) otherwise people can steal your code :-(
http://vbforums.com/forumdisplay.php?s=&forumid=68
make a new thread and it will not be visible :)
How strange nobody commented about my 0.000028495 seconds...
I made it on a Pentium II. :ehh:
Which is the minimum so far? Please show your times like the messagebox does or pass it to seconds like I did.
Greetings... :)
Bodwad, use NoteMe's code (Platipus') to measure the time...
I think yours go around the 0.9 seconds and I believe you can do better than that.
Well, mine was 0,5 ms when I posted...just figured a small improvement and it went down to 0,14 ms for debug configuration and 0,103 ms for release configuration (P4@2,4Ghz, 1GB RAM,W2K Prof,VS.NET 2002). But I think that that's the bottom line for me, I can't see how to squeeze that anymore. Out of curiosity Merri, what's the box you're running your code on ?Quote:
Originally posted by Merri
Woohoo! I finally found out a superb routine! 0,03 ms compiled and 1,1 ms in IDE for 1000 primes. It gives correct results too! :D
Cheers,
NTG
PS: OK. I got curious and wrote it for VB6. With optimizations, runtime gives me 0,076 ms on the same machine.
Quote:
Originally posted by Tec-Nico
How strange nobody commented about my 0.000028495 seconds...
I made it on a Pentium II. :ehh:
Which is the minimum so far? Please show your times like the messagebox does or pass it to seconds like I did.
Greetings... :)
How strange that you didn't notice that I commented it and even asked a question or two about it....;)
Came to tell I dropped below Tec-Nico's reported value, though I have to admit I have a more powerful computer. As for the computer specs, I have told my both computers' specs a few times already, just scroll up ;)
My current result is 0,024 ms and 0,032 ms for the second algorithm. Yea, I have two and I'm working on both. The latter one is younger (just wrote it), so there is still stuff to optimize. I'm really encouraging people, am I not? :D
Edit My newer algorithm passes the older one with big primes: the more primes to count, the faster the new algorithm is in comparison. But I need to make it faster in shorter interval too!
>>> But I think that that's the bottom line for me.
Me and my big mouth. :rolleyes: Sometimes I keep forgeting that the obvious things are always really hard to find. Saw a couple of things again and dropped to 0,06ms for release environment.
What troubles me, however, is something completely trivial that I really stumbled upon. I had a line of code:
While j < 7920 / 2
Innocent, right ? I figured that the compiler would know that this is a constant and substitute for the actual value of 3960. Built (always release env) and I get 0,085 ms. Changed the code to:
While j < 3960
Built again and I get 0,06 ms :eek: ! Geez, I don't know about other people but this came as a surprise to me. The compiler created different IL code for it. Still haven't figured it out completely but there's a conversion to float when I use 7920 / 2. OK, runtime doesn't have a way of knowing what the division will produce so it assumes float but hell, the compiler should figure out that 7920 / 2 is an integer and substitute it! When I changed the statement to While j < 7920 \ 2, I got 0,06 ms again.
Cheers,
NTG
Yeah, NoteMe, I noticed so... But nobody else besides you made a comment about it.
I am working on a better algorithm to see if I can go below what I achieved.
Tsk! It's amazing what a warm bath and a cold beer will do for the thought processes. Okay, came up with a waaaaay simpler algorithm and got my time down to 0.6ms (or 0.027ms if I don't bother showing them)...... I might try .Net out for a laugh and see what I can do...
So it takes about 0.6ms to show them? How?!Quote:
Originally posted by Ex-FB
0.6ms (or 0.027ms if I don't bother showing them)
For me it takes like 3-4ms to show.
I feel like spamming. Now at 0.020XXX ms. I'll be happy if I manage to get past 0.015 ms.
Damn! I can't wait to see how you did it!
:p lol. I'm looking forward to seeing your code Merri. I maxed out at 0,043 ms for VB.Net (0,0407 ms for VB6). That's enough contest fun for me for now. :wave:Quote:
Originally posted by Merri
I feel like spamming. Now at 0.020XXX ms. I'll be happy if I manage to get past 0.015 ms.
Cheers,
NTG
I just hit 80ms... By changing 3 lines I got to 80 from 360... But I'm still far behind :(
Submitted. I couldn't get it below 0,02 ms with the current algorithm, so I ended up sending it. I've spent far too much time on this.
never mind... it went down so much cause it didn't work... I'm back at 360 :cool:Quote:
Originally posted by manavo11
I just hit 80ms... By changing 3 lines I got to 80 from 360... But I'm still far behind :(
Edit: I got it better :) This time I'm at 110ms and working correctly :D On a PIII 500MHz 192 MB RAM. But I'm still at the end of the race :cry:
Hmmm.
Decided to try a more traditional method than what I had.
On my 400 mhz, it averages to .01 seconds.
Without Listboxing, its .0055 seconds.
I guess I'll have to play with my listboxing some more.
-Lou
Yeah, I think I'm pretty much done here.... all I need to do now is make the code look "sexy"....
For the record (and to keep the spirit of competition going) I'm getting
0.3ms to calculate only
and
9ms to calculate and display listbox
on my old Athlon 600 with 64mb Ram
==============================
0.017ms to calculate only
and
0.74ms to calculate and display listbox
on my 1800+ (1.5 ghz) Athlon
================================
0.015ms to calculate only
and
0.6ms to calculate and display listbox
on my 2.4 Intel Celery-stick
==============================
(Guess my old Athlon's graphics card sucks)
Cheers.
I know I have no chance of winning, my only hopes in entering is to not come in last. That being the case will you display all the entries ranked by time?
Eric Dalnas
Yea, we'll show all entries ranked by Score, timing is not the only thing it will be judged on ;).
And Bodwad manages to get the title wrong :rolleyes:, not surprising after he was posting it everywhere else first of all :lol: :D.
:lol:
Its becuase I am supposed to be working so everthing is rushed :afrog:
Is it ok if we use the 1000th prime number in the code? that 7919 could come in handy.
Doesn't say no in the rules...;)Quote:
Originally posted by EricDalnas
Is it ok if we use the 1000th prime number in the code? that 7919 could come in handy.
This is not a solution to a generalized problem, so I don't think that you would break any rules if you use 7919. After all, you can use prime theory to find that out without actually calculating all primes up to 7919. The scope of the contest is very limited so I wouldn't think that anybody would mind your using the number, unless of course Electroman says otherwise. If the contest was about calculating the first n primes (n entered by user and always larger than 1,000,000), that would be a different story, if you needed the last prime you would actually have to calculate it on the spot and it would affect your timing. But then again, in such a case I'm willing to bet that most of our algorithms would break or would be slower than 50,000,000 primes per second.Quote:
Originally posted by EricDalnas
Is it ok if we use the 1000th prime number in the code? that 7919 could come in handy.
BTW, last accomplished time is 0,025 ms. This was entertaining, looking forward to see Merri's code and for the next contest.
Cheers,
NTG
Nobody has answered the timing issue for VB.NET apps yet. sTime should not be used. I'm suggesting the StopWatch class code from mentalis that I've posted earlier.
What are you complaining about, mendhak?
I bet you are the only one doing it on VB .NET so you would win the contest in the VB .NET section :afrog:
That's if Electroman does not allow people posting their VB version and their VB .NET version.
Only one or the other is allowed ;) :D.Quote:
Posted by Tec-Nico
That's if Electroman does not allow people posting their VB version and their VB .NET version.
As for the timing I'm not sure what is gonna be used for VB.NET as I don't think its either me or pino judging that. Could be brad but I'll look into it....