ISO/IEC TR 18015:2006
(Main)Information technology — Programming languages, their environments and system software interfaces — Technical Report on C++ Performance
Information technology — Programming languages, their environments and system software interfaces — Technical Report on C++ Performance
The aim of ISO/IEC TR 18015 is to: give the reader a model of time and space overheads implied by use of various C++ language and library features; debunk widespread myths about performance problems in C++; present techniques for use of C++ in applications where performance matters; and present techniques for implementing C++ standard language and library facilities to yield efficient code. The special needs of embedded systems programming are presented, including ROMability and predictability. A separate chapter presents general C and C++ interfaces to the basic hardware facilities of embedded systems.
Technologies de l'information — Langages de programmation, leurs environnements et interfaces du logiciel système — Rapport technique sur la performance C++
General Information
Standards Content (Sample)
TECHNICAL ISO/IEC
REPORT TR
First edition
2006-09-01
Information technology — Programming
languages, their environments and
system software interfaces — Technical
Report on C++ Performance
Technologies de l'information — Langages de programmation, leurs
environnements et interfaces du logiciel système — Rapport technique
sur la performance C++
Reference number
©
ISO/IEC 2006
PDF disclaimer
This PDF file may contain embedded typefaces. In accordance with Adobe's licensing policy, this file may be printed or viewed but
shall not be edited unless the typefaces which are embedded are licensed to and installed on the computer performing the editing. In
downloading this file, parties accept therein the responsibility of not infringing Adobe's licensing policy. The ISO Central Secretariat
accepts no liability in this area.
Adobe is a trademark of Adobe Systems Incorporated.
Details of the software products used to create this PDF file can be found in the General Info relative to the file; the PDF-creation
parameters were optimized for printing. Every care has been taken to ensure that the file is suitable for use by ISO member bodies. In
the unlikely event that a problem relating to it is found, please inform the Central Secretariat at the address given below.
© ISO/IEC 2006
All rights reserved. Unless otherwise specified, no part of this publication may be reproduced or utilized in any form or by any means,
electronic or mechanical, including photocopying and microfilm, without permission in writing from either ISO at the address below or
ISO's member body in the country of the requester.
ISO copyright office
Case postale 56 • CH-1211 Geneva 20
Tel. + 41 22 749 01 11
Fax + 41 22 749 09 47
E-mail copyright@iso.org
Web www.iso.org
Published in Switzerland
ii © ISO/IEC 2006 – All rights reserved
Contents
Contents . iii
Foreword .v
Introduction .vi
Participants . vii
1 Scope .1
2 Normative References .3
3 Terms and definitions.4
4 Typical Application Areas. 13
4.1 Embedded Systems .13
4.2 Servers .15
5 Language Features: Overheads and Strategies. 16
5.1 Namespaces.16
5.2 Type Conversion Operators .17
5.3 Classes and Inheritance.18
5.4 Exception Handling .27
5.5 Templates.37
5.6 Programmer Directed Optimizations.41
6 Creating Efficient Libraries.63
6.1 The Standard IOStreams Library – Overview.63
6.2 Optimizing Libraries – Reference Example: "An Efficient Implementation of
Locales and IOStreams".64
7 Using C++ in Embedded Systems.77
7.1 ROMability .77
7.2 Hard Real-Time Considerations.81
8 Hardware Addressing Interface .85
8.1 Introduction to Hardware Addressing .86
8.2 The Interface for C and C++ .102
8.3 The Interface for C++ .108
© ISO/IEC 2006 — All rights reserved iii
Technical Report on C++ Performance ISO/IEC TR 18015:2006(E)
Annex A: Guidelines on Using the Interface.118
A.1 Usage Introduction.118
A.2 Using Hardware Register Designator Specifications.118
A.3 Hardware Access .121
Annex B: Implementing the iohw Interfaces. 124
B.1 General Implementation Considerations.124
B.2 Overview of Hardware Device Connection Options .125
B.3 Hardware Register Designators for Different Device Addressing Methods.128
B.4 Atomic Operation.130
B.5 Read-Modify-Write Operations and Multi-Addressing.130
B.6 Initialization.131
B.7 Intrinsic Features for Hardware Register Access.133
B.8 Implementation Guidelines for the Interface .134
Annex C: A Implementation for the
Interface .149
C.1 Implementation of the Basic Access Functions.149
C.2 Buffer Functions.150
C.3 Group Functionality.151
C.4 Remarks.155
Annex D: Timing Code. 156
D.1 Measuring the Overhead of Class Operations .156
D.2 Measuring Template Overheads.165
D.3 The Stepanov Abstraction Penalty Benchmark .171
D.4 Comparing Function Objects to Function Pointers.177
D.5 Measuring the Cost of Synchronized I/O .181
Annex E: Bibliography . 184
iv © ISO/IEC 2006 — All rights reserved
Technical Report on C++ Performance ISO/IEC TR 18015:2006(E)
Foreword
ISO (the International Organization for Standardization) and IEC (the International
Electrotechnical Commission) form the specialized system for worldwide
standardization. National bodies that are members of ISO or IEC participate in the
development of International Standards through technical committees established by the
respective organization to deal with particular fields of technical activity. ISO and IEC
technical committees collaborate in fields of mutual interest. Other international
organizations, governmental and non-governmental, in liaison with ISO and IEC, also
take part in the work. In the field of information technology, ISO and IEC have
established a joint technical committee, ISO/IEC JTC 1.
International Standards are drafted in accordance with the rules given in the
ISO/IEC Directives, Part 2.
The main task of the joint technical committee is to prepare International Standards.
Draft International Standards adopted by the joint technical committee are circulated to
national bodies for voting. Publication as an International Standard requires approval by
at least 75 % of the national bodies casting a vote.
In exceptional circumstances, the joint technical committee may propose the publication
of a Technical Report of one of the following types:
— type 1, when the required support cannot be obtained for the publication of an
International Standard, despite repeated efforts;
— type 2, when the subject is still under technical development or where for any other
reason there is the future but not immediate possibility of an agreement on an
International Standard;
— type 3, when the joint technical committee has collected data of a different kind from
that which is normally published as an International Standard (“state of the art”, for
example).
Technical Reports of types 1 and 2 are subject to review within three years of
publication, to decide whether they can be transformed into International Standards.
Technical Reports of type 3 do not necessarily have to be reviewed until the data they
provide are considered to be no longer valid or useful.
Attention is drawn to the possibility that some of the elements of this document may be
the subject of patent rights. ISO and IEC shall not be held responsible for identifying
any or all such patent rights.
ISO/IEC TR 18015, which is a Technical Report of type 3, was prepared by Joint
Technical Committee ISO/IEC JTC 1, Information technology, Subcommittee SC 22,
Programming languages, their environments and system software interfaces.
© ISO/IEC 2006 — All rights reserved v
Technical Report on C++ Performance ISO/IEC TR 18015:2006(E)
Introduction
“Performance” has many aspects – execution speed, code size, data size, and memory
footprint at run-time, or time and space consumed by the edit/compile/link process. It
could even refer to the time necessary to find and fix code defects. Most people are
primarily concerned with execution speed, although program footprint and memory
usage can be critical for small embedded systems where the program is stored in ROM,
or where ROM and RAM are combined on a single chip.
Efficiency has been a major design goal for C++ from the beginning, as has the principle
of “zero overhead” for any feature that is not used in a program. It has been a guiding
principle from the earliest days of C++ that “you don’t pay for what you don’t use”.
Language features that are never used in a program should not have a cost in extra code
size, memory size, or run-time. If there are places where C++ cannot guarantee zero
overhead for unused features, this Technical Report will attempt to document them. It
will also discuss ways in which compiler writers, library vendors, and programmers can
minimize or eliminate performance penalties, and will discuss the trade-offs among
different methods of implementation.
Programming for resource-constrained environments is another focus of this Technical
Report Typically, programs that run into resource limits of some kind are either very
large or very small. Very large programs, such as database servers, may run into limits of
disk space or virtual memory. At the other extreme, an embedded application may be
constrained to run in the ROM and RAM space provided by a single chip, perhaps a total
of 64K of memory, or even smaller.
Apart from the issues of resource limits, some programs must interface with system
hardware at a very low level. Historically the interfaces to hardware have been
implemented as proprietary extensions to the compiler (often as macros). This has led to
the situation that code has not been portable, even for programs written for a given
environment, because each compiler for that environment has implemented different sets
of extensions.
vi © ISO/IEC 2006 — All rights reserved
Participants
The following people contributed work to this Technical Report:
Dave Abrahams Dietmar Kühl
Mike Ball Jens Maurer
Walter Banks Fusako Mitsuhashi
Greg Colvin Hiroshi Monden
Embedded C++ Technical Committee (Japan) Nathan Myers
Hiroshi Fukutomi Masaya Obata
Lois Goldthwaite Martin O'Riordan
Yenjo Han Tom Plum
John Hauser Dan Saks
Seiji Hayashida Martin Sebor
Howard Hinnant Bill Seymour
Brendan Kehoe Bjarne Stroustrup
Robert Klarer Detlef Vollmann
Jan Kristofferson Willem Wakker
© ISO/IEC 2006 — All rights reserved vii
TECHNICAL REPORT ISO/IEC TR 18015:2006(E)
Information technology — Programming languages,
their environments and system software interfaces —
Technical Report on C++ Performance
1 Scope
The aim of this Technical Report is:
● to give the reader a model of time and space overheads implied by use of various
C++ language and library features,
● to debunk widespread myths about performance problems,
● to present techniques for use of C++ in applications where performance matters,
and
● to present techniques for implementing C++ Standard language and library
facilities to yield efficient code.
As far as run-time and space performance are concerned, if you can afford to use C for
an application, you can afford to use C++ in a style that uses C++’s facilities
appropriately for that application.
This Technical Report first discusses areas where performance issues matter, such as
various forms of embedded systems programming and high-performance numerical
computation. After that, the main body
...
Questions, Comments and Discussion
Ask us and Technical Secretary will try to provide an answer. You can facilitate discussion about the standard in here.