Page 2 of 8 FirstFirst 12345 ... LastLast
Results 41 to 80 of 314

Thread: [Trial]Contest 1 - VB (.NET & Legacy) - Prime Numbers

  1. #41
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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...

  2. #42
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    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.
    Last edited by Merri; Sep 9th, 2004 at 07:57 PM.

  3. #43
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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..

  4. #44
    Fanatic Member alkatran's Avatar
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    860
    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.

  5. #45
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    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.

  6. #46
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    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.
    Last edited by Merri; Sep 9th, 2004 at 08:20 PM.

  7. #47
    Fanatic Member
    Join Date
    Dec 2002
    Location
    North Carolina
    Posts
    734
    That sounds like a good idea, shut off all non system critical processes, and then take the average of the values it returns.

  8. #48
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    My time sucks badly. I realise that my PC is different and that I have a hell of a lot of applications running in the background. It's still bad.
    Have I helped you? Please Rate my posts.

  9. #49
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    My time too......But I am struggeling more with trying to remember how VB worked...

  10. #50
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    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.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  11. #51
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Still wondering what PC he has...and if he ran it in the IDE or as an EXE...

  12. #52
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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.


    Here is how you should use it:


    VB Code:
    1. Private Sub cmdCrunch_Click()
    2.    
    3. Dim Q As New sTime
    4.    
    5.     Q.Init
    6.    
    7.     Q.StartTime
    8.     findPrimes2    'Call your function
    9.     Q.StopTime
    10.    
    11.     MsgBox Q.RetTime
    12.    
    13. End Sub
    Attached Files Attached Files

  13. #53
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Well 19ms...:..I'll blame my PC for that...hehe

  14. #54
    Fanatic Member
    Join Date
    Sep 2002
    Location
    Lexington, SC
    Posts
    586
    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

  15. #55
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    503ms with 100% accuracy using a recordset! Fast for a rs but still bad
    Just want to know what the difference would be.

    Now I will try using a different method. Should be much much
    faster!
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  16. #56
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Originally posted by StevenHickerson
    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
    They are going to post the winning project, I believe, after the contest is over.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  17. #57
    Member
    Join Date
    Apr 2003
    Posts
    43
    Originally posted by NoteMe
    Still wondering what PC he has...and if he ran it in the IDE or as an EXE...
    Gettin 2.8ms on a 2.4 Celeron.... (compiled in VB6) if that helps (that's including populating and showing the listbox).

    Still lot's more to do... I like this.

  18. #58
    Fanatic Member alkatran's Avatar
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    860
    You guys are getting your times in the IDE too, right?
    Don't pay attention to this signature, it's contradictory.

  19. #59
    Member
    Join Date
    Apr 2003
    Posts
    43
    7.9ms in the IDE, but that's probably not as good a test, as a lot of the efficiencies only show up at compilation.

  20. #60
    Member
    Join Date
    Apr 2003
    Posts
    43
    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.

  21. #61
    Fanatic Member alkatran's Avatar
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    860
    Upon compilation I get times of .02 s and lower. Using gettickcount, this means it could be anywhere from 0.5 to -0.5.
    Don't pay attention to this signature, it's contradictory.

  22. #62
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    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.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  23. #63
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    After another modification - but no adding to listbox. So this
    would be 0.0003s? Right?


    Attached Images Attached Images  
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  24. #64
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Hey Mods, are we allowed to make more than one entry for
    this contest?


    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  25. #65

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    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

  26. #66

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    Originally posted by RobDog888
    Hey Mods, are we allowed to make more than one entry for
    this contest?


    no 1 entry per user

  27. #67

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    Originally posted by RobDog888
    They are going to post the winning project, I believe, after the contest is over.
    yep all the apps become visible so you can all take a look

  28. #68

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    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

  29. #69
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    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
    Last edited by Merri; Sep 10th, 2004 at 03:23 AM.

  30. #70
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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....

  31. #71
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Are we allowed to use InLine ASM?

  32. #72
    New Member
    Join Date
    Sep 2004
    Posts
    3

    Thumbs up VB .Net timer

    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..

    Cheers,
    Arun.

  33. #73
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    Originally posted by NoteMe
    Are we allowed to use InLine ASM?
    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?
    Have I helped you? Please Rate my posts.

  34. #74
    ex-Administrator brad jones's Avatar
    Join Date
    Nov 2002
    Location
    Indianapolis
    Posts
    6,614
    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!
    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)

    --------------------------------------------------------------

  35. #75
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    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.

  36. #76
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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...

  37. #77
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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?
    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...

  38. #78
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    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.

  39. #79
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    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.
    Have I helped you? Please Rate my posts.

  40. #80
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    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...

Page 2 of 8 FirstFirst 12345 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width