Back to Search Start Over

Inner loop program construct: A faster way for program execution

Authors :
Adewumi Tosin P.
Source :
Open Computer Science, Vol 8, Iss 1, Pp 115-122 (2018)
Publication Year :
2018
Publisher :
De Gruyter, 2018.

Abstract

Loops are repetitive control structures in programming languages. They are used extensively in many algorithms. The for-loop and while-loop exist, where the former is repeated a number of times while the latter is repeated until a condition is met. Some have asked if re-arranging loops in certain ways can change a program’s speed to produce machine-independent optimisation. Therefore, this research sought to find out if there is any speed difference in a single loop of computations and a loop with an inner loop of same computations. Greater focus is on inner for-loop. The research used a comparative study method in order to evaluate the primary data obtained from running several tests in four popular programming languages: C, C#, Python and R. The Python implementations were further tested on Ubuntu 16 for comparison with results from Windows 10. Results established that, across all languages, there were more computations performed per unit time with an inner for-loop than no inner loop, meaning, given the same number of computations to perform, a loop with an inner for-loop will finish faster. The inner while-loop didn’t perform so well, though. This study will help developers in making better choices with programming language and style.

Details

Language :
English
ISSN :
22991093 and 20180004
Volume :
8
Issue :
1
Database :
Directory of Open Access Journals
Journal :
Open Computer Science
Publication Type :
Academic Journal
Accession number :
edsdoj.43cd775ded245ec852d4622ff1b1404
Document Type :
article
Full Text :
https://doi.org/10.1515/comp-2018-0004