Inner loop program construct: A faster way for program execution

Autor: Adewumi Tosin P.
Jazyk: angličtina
Rok vydání: 2018
Předmět:
Zdroj: Open Computer Science, Vol 8, Iss 1, Pp 115-122 (2018)
Druh dokumentu: article
ISSN: 2299-1093
2018-0004
DOI: 10.1515/comp-2018-0004
Popis: 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.
Databáze: Directory of Open Access Journals