Originally posted by alkatran What if I do the opposite of indenting? You know, indenting the lines outside a loop?
I'm including my own timing code, but it can be removed easily (only 3 lines, using gettickcount). Problem though, it doesn't always return the same value? Range from .47s to .58s, but I have things running. Will the timing tests be done multiple times, and the average taken?
I wish Pino answered this yesterday....I have asked all of these questions in PMs to Pino, and he didn't answer them well.......BTW GetTickCount is not good enough.......it has tooo big Ticks...
Ok, at the moment my results with 30000 primes is that it is faster to calculate the primes than filling the listbox with the items (unless I set ListBox hidden while populating it).
My suggestion for the benchmarking is to run the code a few million times or more doing the same call and then time that. Place the code behind a command button, it makes benchmarking a whole lot easier. Times may vary a lot with GetTickCount (up to 300 ms at worst), so the longer it takes to test, the more accurate the results will be.
Also, I suggest turning all of the advanced optimizations on when you compile the benchmarks. It really does matter a lot. And if someone have made a code that doesn't work with advanced optimizations... well, too bad. Error checking is important!
Edit I'm currently at 7 ms. I included all code within the check, including clearing the listbox. We can't compare the times too well though, different computers.
I have tested a lot today...and it looks like the simples ways of calculating the 1000 first primes is the fastest ones...advanced algoritms takes to much time on soooo few primes.....I will go to bed now and see if the number will be raised, if so then there will be some more advanced code winning then the simplest one...and I would have to change it after all..
Wow, 7 milliseconds. I just chopped mine from .46 to .16
Although I haven't exactly researched it much.
Also, I fill an array with the primes, then get the time, THEN do all the output. We are timing the generation, after all. Method of output (file, listbox) shouldn't affect score.
Um, you are finding the first 1000 primes, and not the primes up to 1000, right?
Don't pay attention to this signature, it's contradictory.
Posted by alkatran What if I do the opposite of indenting? You know, indenting the lines outside a loop?
I'm including my own timing code, but it can be removed easily (only 3 lines, using gettickcount). Problem though, it doesn't always return the same value? Range from .47s to .58s, but I have things running. Will the timing tests be done multiple times, and the average taken?
You might want to remove that before submitting your code. Mainly because its extra overhead, we won't go thoguh the code and comment out things like this .
As for the point with the populating the listbox taking up alot of time I suggest when its judged we comment out the lines that populate the listbox when doing the speed tests but uncomment them for checking the values .
Another option would be if the algo just put the values in a simple array then after that another funtion puts the array into the listbox afterwards. That way we can exclude the final stage when timing .
When your thread has been resolved please edit the original post in the thread ()
and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.
Just set ListBox.Visible = False before you start populating it and ListBox.Visible = True after you're done. My 7 ms includes filling the and clearing the listbox.
Edit When I take out the clearing and hiding/viewing the listbox, I get into 5 ms. If I wouldn't populate the listbox within the main loop, I'd probably go under 1 ms.
Edit #2 Yup, it goes under 1 ms. I get 30000 primes in 100 ms.
1 ms! I kinda thought that Merri would be the one at the top
when all the dust settles. I'm not even below 100ms yet. This is
just what I wanted to know.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
For everyone that is trying and don't know how to time their apps properly here is a class that the good old Platipus made some years ago. Don't think I have changed much in it. So the credit goes to him.
Geeze do you guys just have those algo's just sitting around? lol.
I've never worked with prime numbers before and just from reading up today and making my own algo I got down to a time of 300 ms... I thought that was pretty impressive, yall are sitting here talking about 19, 7, and 1 even!..... Dosn't that kind of just ruin the spirit of the contest lol.
After the contest is over if I could get my hands on one of those algos just to see how it works I'd be gratefull
Originally posted by StevenHickerson
I've never worked with prime numbers before and just from reading up today and making my own algo I got down to a time of 300 ms... I thought that was pretty impressive, yall are sitting here talking about 19, 7, and 1 even!..... Dosn't that kind of just ruin the spirit of the contest lol.
It's just for fun. Regardless of who wins, who cares, I for one still enjoy little challenges like this. It's like crossword puzzles in newspapers, it get's the brain juices flowing.
Originally posted by NoteMe I wish Pino answered this yesterday....I have asked all of these questions in PMs to Pino, and he didn't answer them well.......BTW GetTickCount is not good enough.......it has tooo big Ticks...
i thought i answered this note me You can add your own timings but please remove them before submiting as i have set up my own timing system
yes i will take the average of a group of data
Listen guys dont get hooked up on how i am going to time it, just develop the fastest most efficiant code you can
The class module NoteMe provided isn't giving good results on too fast codes. The times it gives makes no sense to me. First it can give something like:
8.22something
7.9something
1.7something
And when I change to 30000 primes, I can get the same as above and 0.100something
Only the last one matched somehow with the time given by my module. I guess the class module would love to get a longer taking code.
Originally posted by Merri The class module NoteMe provided isn't giving good results on too fast codes. The times it gives makes no sense to me. First it can give something like:
8.22something
7.9something
1.7something
And when I change to 30000 primes, I can get the same as above and 0.100something
Only the last one matched somehow with the time given by my module. I guess the class module would love to get a longer taking code.
Edit I have Athlon XP 2200+ @ 1800 MHz
It is given in seconds....and watch out, when the numbers are small VB uses sientific numbers... Make sure it is not 8.22*10^(-2)... It uses the E you know...
Update: 6Ms in my IDE
Exe : 4Ms
Using 1,4Ghz CPU
Maybe If Pino have a kick ass GPU, it would nearly 100% for sure be faster to write a shader, and let the GPU do the crunching......am I allowed....J/K....
Timing will be done on the code you submit. This means if there is timing code in your listing or any other bells and whistles, it will be timed as well. (and thus increase your program's exexcution time). The judges will not comment or remove code in any way for the timings.
If the rules don't say it, then it is fair. I was going to actually do a hardcoded listing of the prime numbers as well - because that didn't violate the rules. Granted, this would not be a very 'sexy' solution, thus while it might be fastest, I doubt it would win.
If there are changes to the rules after a contest has started, then those changes need to be highlighted with the[hl] tag and anyone that has submitted needs to be able to resubmit.
Brad!
Have you given out your reputation points today? Select the Rate This Post link to give points for good posts!
-------------------------------------------------------------
Brad! Jones
Lots of Software, LLC (I wrote: C Programming in One Hour a Day)(Dad Jokes Book)(Follow me on Twitter)
--------------------------------------------------------------
Just to let you know, for those that have ventured into the entries sub-forum already. I have altered the instructions for posting your entries. It did read that you should reply to the thread already there but it now says you should create a new thread for each entry.
When your thread has been resolved please edit the original post in the thread ()
and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.
Originally posted by brad jones
If the rules don't say it, then it is fair. I was going to actually do a hardcoded listing of the prime numbers as well - because that didn't violate the rules. Granted, this would not be a very 'sexy' solution, thus while it might be fastest, I doubt it would win.
I'm just making sure, comments don't matter at all do they? I mean, when you compile it, all the coments are gotten rid of right?
True...they are ignored by the compiler...and will not make a diffrence for others then the mods that will read the code
An other question...will the test be in the IDE or Compiled...if it is in the IDE then I hate you, and if it is compiled....what kind of CPU do you have Pino...what brand/type/speed and so on...
Posted by NoteMe An other question...will the test be in the IDE or Compiled...if it is in the IDE then I hate you, and if it is compiled....what kind of CPU do you have Pino...what brand/type/speed and so on...
Out of fairness it would be likely that more than one PC will be used, I would also suggest its run in the IDE, we don't want the speeds to be too fast to measure now .
When your thread has been resolved please edit the original post in the thread ()
and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.
When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.
Originally posted by Acidic Maybe you should use one of those old 25MHz processor PCs. I have one somewhere, no hold on, it's in sweden, and its HDD is here.
Probably not a 32bit processor.....or maybe it is...well anyway...NO WAY...