Upon compilation I get times of .02 s and lower. Using gettickcount, this means it could be anywhere from 0.5 to -0.5. :rolleyes: :D
Printable View
Upon compilation I get times of .02 s and lower. Using gettickcount, this means it could be anywhere from 0.5 to -0.5. :rolleyes: :D
Download the sTime class and add it into your command button event.
I'm getting 0.058s according to the class timer which seems
accurate accross several runs. Didnt vary more than 0.001s overy
25 runs.
After another modification - but no adding to listbox. So this
would be 0.0003s? Right?
http://www.vbforums.com/attachment.p...postid=1783691
Hey Mods, are we allowed to make more than one entry for
this contest?
:confused:
Hey all wow, over night there has been a lot of replies, i have allready set up a timing system :) you guys just worry about the coding,
I will most likly compile the code, but if it gets to close run it from the ide
my system
pentium 4 2.6ghz :)
i'm going to have to rfead through your questions, i'll answer as many as i can
no :) 1 entry per userQuote:
Originally posted by RobDog888
Hey Mods, are we allowed to make more than one entry for
this contest?
:confused:
yep all the apps become visible so you can all take a lookQuote:
Originally posted by RobDog888
They are going to post the winning project, I believe, after the contest is over.
i thought i answered this note me :confused: You can add your own timings but please remove them before submiting as i have set up my own timing systemQuote:
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...:D....BTW GetTickCount is not good enough...;)....it has tooo big Ticks...;)
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.
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...;)Quote:
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
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...:D...am I allowed..:D..J/K....
Are we allowed to use InLine ASM?
To measure the time for the VB .Net code use the following timer. I think this is quite accurate and consistent and simple to add to ur code.
http://www.mentalis.org/soft/class.qpx?id=8
Best of luck..:thumb:
Cheers,
Arun.
No! I hopeQuote:
Originally posted by NoteMe
Are we allowed to use InLine ASM?
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?
Just some comments:
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!
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.
Quote:
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.
Don't steal my idea...:D
True...they are ignored by the compiler...and will not make a diffrence for others then the mods that will read the codeQuote:
Originally posted by Acidic
No! I hope
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?
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...:D
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 ;).Quote:
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...:D
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..:D...or maybe it is...well anyway...NO WAY...:DQuote:
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.
Ah - but some efficiencies of code, only appear when you compile the program and aren't applicable to the interpreted version.Quote:
Originally posted by Electroman
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 ;).
Quote:
Originally posted by Ex-FB
Ah - but some efficiencies of code, only appear when you compile the program and aren't applicable to the interpreted version.
Exactly...I wote for Native code...
Me too....... god help me if it comes down "sexyness" of code, as mine looks like a dogs dinner (and I've broken more than one of the cardinal rules of programming) :p
What sort of timings are people getting?
I just maxed out at a rather uninspiring 10ms (generation, listbox insertion and display) as an average of runs 2, 3 and 4.
Its as fast as this algorithm will go on my machine (1.5ghz Celery processor). I'm using GetTickCount though and the lowest resolution that it has is about 10ms anyway, so it could be a little faster than that :) Does anyone know what timing methods the mods are going to use?
But I'm happy to say I invented the alg about 2 years ago. I hope it is unique (I bet its not though, I have a sneaking suspicion that NoteMe is using the same or similar).
I'm ready to submit my work now but the thread is closed :(
You have to make a new thread :)Quote:
Originally posted by wossname
What sort of timings are people getting?
I just maxed out at a rather uninspiring 10ms (generation, listbox insertion and display) as an average of runs 2, 3 and 4.
Its as fast as this algorithm will go on my machine (1.5ghz Celery processor). I'm using GetTickCount though and the lowest resolution that it has is about 10ms anyway, so it could be a little faster than that :) Does anyone know what timing methods the mods are going to use?
But I'm happy to say I invented the alg about 2 years ago. I hope it is unique (I bet its not though, I have a sneaking suspicion that NoteMe is using the same or similar).
I'm ready to submit my work now but the thread is closed :(
Quote:
Originally posted by wossname
But I'm happy to say I invented the alg about 2 years ago. I hope it is unique (I bet its not though, I have a sneaking suspicion that NoteMe is using the same or similar).
It won't help as long as Merri is faster...someone with more time on their hands then me needs to beat that guy....:D
I just submitted my entry.
So what has Merri got under the hood of his app then? Anything we've heard of?
I get 1.3 in the IDE and 1 when it's compiled. This is in a 1.9 MGHz thingy. That includes everything. I know it needs to be faster.
aah, damn me for not thinking of this earlier. 1 in IDE, 0.8 compiled. I didn't think to not check with numbers that are greater than 1/2 the number i'm currently at.
Quote:
Originally posted by Acidic
I get 1.3 in the IDE and 1 when it's compiled. This is in a 1.9 MGHz thingy. That includes everything. I know it needs to be faster.
aah, damn me for not thinking of this earlier. 1 in IDE, 0.8 compiled. I didn't think to not check with numbers that are greater than 1/2 the number i'm currently at.
Not you too...well then it is two and a half persons that is faster then me...:D
I emulated PragmaPack from C++ and made the nicest algo untill now....it is sooooo nice and fast....does 1,000,000 primes in less then a second on my 1,4Ghz (without adding to list box) the problem is that it is impossible to add all the entries in that loop, so I have to have an other loop after it, and at compiled that makes it do 1000 primes in 4.3-4.4ms, that is a bit slower then the old boring algo that does 1000 primes in 4.2-4.3, hmmmm....what should I submit, the sexy pragma pack code that is 0.1-0.2ms slower or the fastest one....I can't win over Merris speed anyway....
ØØ
I have a bit of a confusion here.
Adding 1000 items to a listbox itself takes a considerable number of milliseconds. For example, with a very simple loop, like this:
VB Code:
Dim tm As Integer Dim i As Integer tm = Environment.TickCount For i = 1 To 1000 ListBox1.Items.Add(i.ToString) Next Console.WriteLine(Environment.TickCount - tm)
I got 40 ms.
How is it that some of you are able to generate the primes and populate the listbox in less than 4 ms?
:confused:
The best I've gotten so far, including generation and population of the listbox is 42 ms.
(See that wossname? 42!!) :D
mendhak set your box invisible before you add and visible after you add :).. VB is trying to refresh the listbox view while your adding stuff.
Yes, thanks. Also, I looked through Listbox's properties, and found a bunch of methods they've included for efficiency.
I am now down to 8ms.
Might as well submit it, then. I'd really like to see if I come in at position # 42. :D
I am very interested to see what others have written.
Ok after looking at some timings code we are going to use noteme's timing method :) simply because you can all test your code :) and it does the job
(if this is still ok with noteme, if not please contact me)
Stime
You can find it on the second page of this thread!
That's for VB6. I wouldn't like to use it in VB.NET. I'm using this for timing right now, someone had posted a link to it in this thread:Quote:
Originally posted by Pino
Ok after looking at some timings code we are going to use noteme's timing method :) simply because you can all test your code :) and it does the job
(if this is still ok with noteme, if not please contact me)
Stime
You can find it on the second page of this thread!
VB Code:
Imports System Imports System.Runtime.InteropServices Namespace Org.Mentalis.Utilities Public NotInheritable Class StopWatch Private m_StartTime As Long Private m_Frequency As Long Private Declare Ansi Function QueryPerformanceCounter Lib "kernel32.dll" (ByRef x As Long) As Integer Private Declare Ansi Function QueryPerformanceFrequency Lib "kernel32.dll" (ByRef x As Long) As Integer Public Sub New() Frequency = GetFrequency() Reset() End Sub Public Sub Reset() StartTime = GetValue() End Sub Public Function Peek() As Long Return CType((((GetValue() - StartTime) / CType(Frequency, Double)) * 10000), Long) End Function Private Function GetValue() As Long Dim ret As Long = 0 If QueryPerformanceCounter(ret) = 0 Then Throw New NotSupportedException("Error while querying the high-resolution performance counter.") Return ret End Function Private Function GetFrequency() As Long Dim ret As Long = 0 If QueryPerformanceFrequency(ret) = 0 Then Throw New NotSupportedException("Error while querying the performance counter frequency.") Return ret End Function Private Property StartTime() As Long Get Return m_StartTime End Get Set(ByVal Value As Long) m_StartTime = Value End Set End Property Private Property Frequency() As Long Get Return m_Frequency End Get Set(ByVal Value As Long) m_Frequency = Value End Set End Property End Class End Namespace
To use it,
VB Code:
Dim sw As New StopWatch 'your code, etc etc Label1.Text = (sw.Peek() / 10).ToString 'Time elapsed.
Mend, what unit of time is that giving out? Milliseconds?
Sadly my app just can't compete with the big boys.
My algorithm just aint powerful enough. :(
It gives out tens of milliseconds. :ehh:Quote:
Originally posted by wossname
Mend, what unit of time is that giving out? Milliseconds?
Sadly my app just can't compete with the big boys.
My algorithm just aint powerful enough. :(
Which is why when you want the milliseconds, you must divide by 10.
And don't worry, my algo has been written in such a way that it'll always be almost but not quite, as powerful as yours. :) I think I should be getting extra points just for the prophetic powers of my algo :D
How did you time yours, btw? I hope you're not using the Environment.GetTick. :sick:
Submitted.
So does that mean its only acurate to every 10ms? or Tenths of ms?Quote:
Posted by mendhak
It gives out tens of milliseconds. :ehh:
Which is why when you want the milliseconds, you must divide by 10.
BTW I'm not sure if I said this before in this thread but you know the VB6 & VB.NET ones will be judged seperatly so there should be two winners, the speed of a VB6 app & VB.NET app can't really compete fairly? :)
P.S. Which one is Merri using? ;)
Quote:
Originally posted by mendhak
Yes, thanks. Also, I looked through Listbox's properties, and found a bunch of methods they've included for efficiency.
WHat properties was that....I turned them on an off all night yesterday, and came no where...:D...maybe it only works for .NET.....I don't have that..well we have it at school tho'....
No problem. It was the good old Platipus that started that code anyway. Havn't changed much in it. And he never minded us using it in the game section to test the speed of diffrent implementations, so then I guess he won't mind this either...Quote:
Originally posted by Pino
Ok after looking at some timings code we are going to use noteme's timing method :) simply because you can all test your code :) and it does the job
(if this is still ok with noteme, if not please contact me)
Stime
You can find it on the second page of this thread!
I don't think it's there in VB6. I don't have VB6 on this machine, or I'd check. PM Wossy for more info, I think he's using the same thing. :DQuote:
Originally posted by NoteMe
WHat properties was that....I turned them on an off all night yesterday, and came no where...:D...maybe it only works for .NET.....I don't have that..well we have it at school tho'....
:lol:
I've submitted my app but I am still playing with my code.
Ignoring the listbox entirely and just timing the algorithm, I can get 2ms, I'm happy with that :D (1.5ghz celeron, XP Home edition), with browser and IDE running at the same time.
The Listbox should be banned for being a resource hog. :D
I completly agree....my algo takes less then 1ms without the Listbox, the list box it self takes 4,5ms or so in the IDE...:DQuote:
Originally posted by wossname
:lol:
I've submitted my app but I am still playing with my code.
Ignoring the listbox entirely and just timing the algorithm, I can get 2ms, I'm happy with that :D (1.5ghz celeron, XP Home edition), with browser and IDE running at the same time.
The Listbox should be banned for being a resource hog. :D
Everyone that feels the same way as me about compiled versus IDE timing of our apps. Please add this to your Form_Load event:
Or if you realy dare:Code:On Error Resume Next
Debug.Print 1 / 0
If Err Then
MsgBox "The contest should only be ran with compiled apps." & vbCrLf & "Please Compile this app.", , "Please Compile"
End If
Code:On Error Resume Next
Debug.Print 1 / 0
If Err Then
MsgBox "The contest should only be ran with compiled apps." & vbCrLf & "Please Compile this app.", , "Please Compile"
Unload Me
End If
Code:On Error Resume Next
Debug.Print 1 / 0
If Err Then
CorruptWindowsPartition() ':D :lol:
Unload Me
End If
dont want to sound like a kill joy but could we keep this thread for questions relating to the contest and not chit chat :)
i think i will have a go even though i have never worked with prime numbers before just for experience.
my question is, will the code have to be NON api or does anything go.
thank you.
casey.
you can do anything with your app as long as you follow the rules, the rules specify you must
generate the first 1000 prime numbers
display them ina listbox
and not use 3rd party controls :)
How about, just to make it more interesting, not allowing the use
of any of the popular algorithms. As most know, all you have to
do is google prime numbers or such and you can find an accurate
algorithm. Not much competition in copying someone elses
formula.
:D
Well think of it this way rob, if me and merri use the same algorithm one of us will implement it in a more efficient manner ( no not me ).
Yes, but I was just thinking that there are going to be many
entries using the same alogo. Keeping those popular alogos out
would make it interesting to see the creativity factor come into
play. No biggie though. I know mine is fast, but not as fast as
Merri's. Dont seem very competitive now. As I'm sure others know
that they cant beat Merri either. Nothing against Merri to say the
least.
:)
So again....to get the final answer....will the testing be done after you have compiled it, or in the IDE.....for some implementations it is a big diffrence because of the way 32bit CPUs work....Quote:
Originally posted by Pino
dont want to sound like a kill joy but could we keep this thread for questions relating to the contest and not chit chat :)
And yeah. I am still voting for compiled code. Thats what the app would have been in the real world anyway.....
ØØ
No no no..don't post it here.....
Darn it, the first time through is always slower than consecutive times. Getting slightly different timing results from consecutive runs (am using posted StopWatch.vb class).
Average results: 0,5 ms for calculating and 0,8 ms totally. Using .Net on [email protected].
Cheers,
NTG
You should all feel comfort in the fact my machine will probably run them all below 1ms: 3GHz (800 FSB, hyperThreading) 2GB 400MHz Dual Channel DDR :D
Problem is I can only do the VB6 ones as I don't have the VB.NET IDE :(.
Although you said third party controls are disallowed, could we possibly use our own controls if we just wrap code in them?
I will initially run it through my 2.6ghz pc if the timing are all very close might try it ona slower machine as well (400 mhz) :)
Hey, I think I've posted on the wrong place :cry:
I created a new thread at VBForums.com>General>VBForums Coding Contests>Contest Entries. Is that ok or should I create a new thread at VBForums.com>General>VBForums Coding Contests>Contest Entries>Prime Numbers Entry Thread ?
Cheers,
Nick
yea the first one was right, the entries don't become visible untill the contest is over ;).Quote:
Posted by ntg
Hey, I think I've posted on the wrong place :cry:
I created a new thread at VBForums.com>General>VBForums Coding Contests>Contest Entries. Is that ok or should I create a new thread at VBForums.com>General>VBForums Coding Contests>Contest Entries>Prime Numbers Entry Thread ?
Cheers,
Nick