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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Does virtual function really influence the performance?

Does virtual function really influence the performance?

Scheduled Pinned Locked Moved C / C++ / MFC
c++hardwareperformancetutorialquestion
2 Posts 2 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.
  • C Offline
    C Offline
    code_discuss
    wrote on last edited by
    #1

    I keep reading articles which say virtual function has overhead on performance, but I'd like to know how much is it? For example, the MFC framework, if all the functions inside are virtual, how much will MFC's performance decrease, for the current 1GHz/512M PC hardware ?:confused:

    A 1 Reply Last reply
    0
    • C code_discuss

      I keep reading articles which say virtual function has overhead on performance, but I'd like to know how much is it? For example, the MFC framework, if all the functions inside are virtual, how much will MFC's performance decrease, for the current 1GHz/512M PC hardware ?:confused:

      A Offline
      A Offline
      Arman S
      wrote on last edited by
      #2

      Yes there is overhead on performance. But it is very important to understand the virtue/performace relation when using virtual functions. I mean, one should avoid using virtual functions in low level operations such as accessing each character in a sequence. But for not so heavy and/or intensive operations you can [and sometimes should] ignore performance issues. As for MFC, a good candidate area of using virtual functions is message handlers. But MFC refused virtual functions and used message maps. Really, so many classes with so many virtual functions would indeed decrease speed and increase memory usage.

      -- ===== Arman

      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