Exploring the Access to the Static Array Elements via Indices and via Pointers — the Introductory C++ Case Expanded
Journal: Journal of Information and Organizational Sciences (JIOS) (Vol.48, No. 1)Publication Date: 2024-06-16
Authors : Robert Logožar; Matija Mikac; Danijel Radošević;
Page : 49-80
Keywords : static arrays; pointers; C/C++; accessing the array elements; benchmarks;
Abstract
We revisit the old but formally still unresolved debate on the time efficiency of accessing the elements of 1D arrays via indices versus accessing them via pointers. To analyze that, we have programmed benchmarks of minimal complexity in the C++ language and inspected the machine code of their compilation in the x86 assembly language. Before exploring the performance, we briefly compared a few methods used for the execution time measurements. The results on the Wintel platform show no significant advantage in using pointers over indices except for some benchmarks and array (data) types. In other cases, the exact opposite may be true. The cause of this inconsistency lies in the compilation of the source code into the rather nonorthogonal x86 instruction set. Furthermore, the execution speed does not clearly relate to the instruction length. The parallel aim of this work is to provide a ground for further analysis and measurements of this kind using different compilers, languages, and computer platforms.
Other Latest Articles
- IMPROVE THE SAFETY OF AIR TRANSPORT, ESPECIALLY IN MILITARIZED TERRAIN, BY USE OF SIDE LOOKING AIRBORNE RADAR AND SPACE TIME ADAPTIVE PROCESSING
- A MODEL FOR ASSESSING SHIPPING SAFETY WITHIN PROJECT-ORIENTATED RISK MANAGEMENT BASED ON HUMAN ELEMENT
- INVESTIGATION ON THE DYNAMICS OF MOVEMENT OF CYLINDRICAL CLEANING PIGS THROUGH THE BENDS OF PIPELINE SYSTEMS FOR FLUID TRANSPORTATION
- Entrepreneur’s strategy leveraged and monitored by the interrelation of ERP and BSC
- USERS’ SATISFACTION WITH INTERCITY BUS TERMINAL QUALITY IN LAGOS STATE, NIGERIA
Last modified: 2024-07-09 21:17:34