Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Speed MyDriver Day !!!

Speed MyDriver Day !!!

Scheduled Pinned Locked Moved C#
performance
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    morisson_c
    wrote on last edited by
    #1

    My Code is runnnig the same function 100000000000000000 times a day I want to speed my function runnig time. so...the qst is: which type of code is more effective: return Convert.ToBoolean((var >> n) & 0x1)); or if (((var >> n) & 0x1) == 0) return true; else return false; :-\

    R B 2 Replies Last reply
    0
    • M morisson_c

      My Code is runnnig the same function 100000000000000000 times a day I want to speed my function runnig time. so...the qst is: which type of code is more effective: return Convert.ToBoolean((var >> n) & 0x1)); or if (((var >> n) & 0x1) == 0) return true; else return false; :-\

      R Offline
      R Offline
      Rob Philpott
      wrote on last edited by
      #2

      Almost certainly the second I'd have thought, although they appear to return the opposite of each other your two methods. With stuff like this, stick it in a loop and time it for millions of times, you'll soon get any idea of which method is best. Having said that, in my experience what works well on an AMD based machine may not be the best way of Intel and vice-versa. To do with the JITing I'd imagine.

      Regards, Rob Philpott.

      M 1 Reply Last reply
      0
      • R Rob Philpott

        Almost certainly the second I'd have thought, although they appear to return the opposite of each other your two methods. With stuff like this, stick it in a loop and time it for millions of times, you'll soon get any idea of which method is best. Having said that, in my experience what works well on an AMD based machine may not be the best way of Intel and vice-versa. To do with the JITing I'd imagine.

        Regards, Rob Philpott.

        M Offline
        M Offline
        morisson_c
        wrote on last edited by
        #3

        This is not my true code...You right I have a mistake in my example tnx for your help

        1 Reply Last reply
        0
        • M morisson_c

          My Code is runnnig the same function 100000000000000000 times a day I want to speed my function runnig time. so...the qst is: which type of code is more effective: return Convert.ToBoolean((var >> n) & 0x1)); or if (((var >> n) & 0x1) == 0) return true; else return false; :-\

          B Offline
          B Offline
          Bekjong
          wrote on last edited by
          #4

          return ((var >> n) & 0x1) == 0);

          Probably faster than the first solution.

          Standards are great! Everybody should have one!

          M 1 Reply Last reply
          0
          • B Bekjong

            return ((var >> n) & 0x1) == 0);

            Probably faster than the first solution.

            Standards are great! Everybody should have one!

            M Offline
            M Offline
            morisson_c
            wrote on last edited by
            #5

            work faster...tnx. :-D

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups