• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            asm, c, c++ are my all
            -- Core In Computer
            posts - 139,  comments - 123,  trackbacks - 0

            /********************************************\
            |????歡迎轉載, 但請保留作者姓名和原文鏈接, 祝您進步并共勉!???? |
            \********************************************/


            C++對象模型(13) - 3.5 Object Member Efficiency
            作者: Jerry Cat
            時間: 2006/11/17
            鏈接:?
            http://m.shnenglu.com/jerysun0818/archive/2006/11/17/15311.html


            3.5 Object Member Efficiency
            ;-----------------------------------------------------------------------

            An obvious observation is that without the optimizer turned on, it is extremely difficult to guess at the performance characteristics of a program, since the code is potentially hostage to the "quirk(s) of code generation…unique to a particular compiler." Before one begins source level "optimizations" to speed up a program, one should always do actual performance measurements rather than relying on speculation and common sense.不要想當然, 要試驗之.

            In the next sequence of tests, I introduced first a three-level single inheritance representation of the Point abstraction and then a virtual inheritance representation of the Point abstraction. I tested both direct and inline access (multiple inheritance did not fit naturally into the model, so I decided to forego it.) The general hierarchy is

            class Point1d {...};?????????????????????????? // maintains x
            class Point2d : public Point1d {...};???? // maintains y
            class Point3d : public Point2d {...};???? // maintains z

            The one-level virtual inheritance derived Point2d virtually from Point1d. The two-level virtual inheritance additionally derived Point3d virtually from Point2d. Table 3.2 lists the results of running the tests for both compilers. (Again, I break out the times for the two compilers only when their performances differ significantly from each other's.)

            Table 3.2. Data Access under Inheritance Models

            ???????????????????????????????????? Optimized?????? Non-optimized
            Single Inheritance
            ???? Direct Access?????????? 0.80???????????????? 1.42
            ???? Inline Methods
            ???? CC???????????????????????????0.80??????????????? 2.55
            ???? NCC????????????????????????0.80??????????????? 3.10
            ?
            Virtual Inheritance — 1-Level
            ???? Direct Access??????????? 1.60????????????? 1.94
            ???? Inline Methods
            ???? CC????????????????????????????1.60????????????? 2.75
            ???? NCC?????????????????????????1.60????????????? 3.30
            ?
            Virtual Inheritance — 2-Level
            ???? Direct Access
            ???? CC????????????????????????????2.25????????????? 2.74
            ??? ?NCC?????????????????????????3.04????????????? 3.68
            ?
            ??? Inline Methods
            ???? CC????????????????????????????2.25????????????? 3.22
            ???? NCC?????????????????????????2.50????????????? 3.81
            ?
            Single inheritance should not affect the test performance, since the members are stored contiguously within the derived class object and their offsets are known at compile time. The results, as expected, were exactly the same as those of the independent abstract data type. (The same should be true under multiple inheritance, but I didn't confirm that.)

            Again, it is worth noting that with the optimizer off, performance, which common sense says should be the same (direct member access versus inline access), is in practice slower in the case of inline functions. The lesson again is that the programmer concerned with efficiency must actually measure the performance of his or her program and not leave the measurement of the program to speculation and assumption. It is also worth noting that optimizers don't always work. I've more than once had compilations fail with an optimizer turned on that compiled fine "normally."別想當然, 實驗之! 編譯時盡可能打開優化開關.

            The virtual inheritance performance is disappointing in that neither compiler recognized that the access of the inherited data member pt1d::_x is through a nonpolymorphic class object and that therefore indirect runtime access is unnecessary. Both compilers generate indirect access of pt1d::_x (and pt1d::y in the case of two levels of virtual inheritance), even though its location within the two Point3d objects is fixed at compile time. The indirection significantly inhibited the optimizer's ability to move all the operations within registers. The indirection did not affect the non-optimized executables significantly.
            虛繼承導致性能大降, 即使打開優化開關也沒太大起色.

            posted on 2006-11-17 18:11 Jerry Cat 閱讀(725) 評論(0)  編輯 收藏 引用

            <2025年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            常用鏈接

            留言簿(7)

            隨筆檔案

            最新隨筆

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久精品中文字幕无码绿巨人| 亚洲国产精品无码成人片久久| 久久99精品久久久久久久不卡| 久久精品aⅴ无码中文字字幕不卡 久久精品aⅴ无码中文字字幕重口 | 亚洲嫩草影院久久精品| 久久99精品久久久久久野外| 国产欧美久久久精品影院| 无码人妻精品一区二区三区久久久| 2022年国产精品久久久久| 久久国产福利免费| 久久国产热精品波多野结衣AV| 精品久久久久久无码中文字幕| 成人午夜精品无码区久久| 夜夜亚洲天天久久| 久久婷婷五月综合国产尤物app| 久久久久亚洲AV成人网人人网站 | 一本久久a久久精品综合香蕉| 狠狠色婷婷久久一区二区三区| 青青久久精品国产免费看| 无码国内精品久久人妻蜜桃| 日韩久久久久中文字幕人妻| 国产精品无码久久久久久| 亚洲国产综合久久天堂| 精品熟女少妇aⅴ免费久久| 91久久精品91久久性色| 午夜不卡久久精品无码免费| 无码任你躁久久久久久久| 久久人人爽人人爽人人片AV麻豆 | 久久强奷乱码老熟女网站| a高清免费毛片久久| 一本色道久久HEZYO无码| 亚洲美日韩Av中文字幕无码久久久妻妇 | 久久久久一区二区三区| 国产精品一区二区久久精品| 粉嫩小泬无遮挡久久久久久| 亚洲国产精品无码久久久蜜芽| 国产免费久久精品99re丫y| 亚洲国产成人乱码精品女人久久久不卡 | 久久国产免费观看精品| 久久久久人妻一区二区三区vr| 久久精品一本到99热免费|