Inner loop program construct: A faster way for program execution

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 wa...

Full description

Bibliographic Details
Main Author: Adewumi Tosin P.
Format: Article
Language:English
Published: De Gruyter 2018-08-01
Series:Open Computer Science
Subjects:
Online Access:http://www.degruyter.com/view/j/comp.2018.8.issue-1/comp-2018-0004/comp-2018-0004.xml?format=INT
_version_ 1818519090503876608
author Adewumi Tosin P.
author_facet Adewumi Tosin P.
author_sort Adewumi Tosin P.
collection DOAJ
description 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.
first_indexed 2024-12-11T01:19:00Z
format Article
id doaj.art-d43cd775ded245ec852d4622ff1b1404
institution Directory Open Access Journal
issn 2299-1093
language English
last_indexed 2024-12-11T01:19:00Z
publishDate 2018-08-01
publisher De Gruyter
record_format Article
series Open Computer Science
spelling doaj.art-d43cd775ded245ec852d4622ff1b14042022-12-22T01:25:47ZengDe GruyterOpen Computer Science2299-10932018-08-018111512210.1515/comp-2018-0004comp-2018-0004Inner loop program construct: A faster way for program executionAdewumi Tosin P.0Computer Sciences Department, University of Lagos,Lagos, NigeriaLoops 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.http://www.degruyter.com/view/j/comp.2018.8.issue-1/comp-2018-0004/comp-2018-0004.xml?format=INTfor loopwhile loopprogramming languageswindows 10optimisation
spellingShingle Adewumi Tosin P.
Inner loop program construct: A faster way for program execution
Open Computer Science
for loop
while loop
programming languages
windows 10
optimisation
title Inner loop program construct: A faster way for program execution
title_full Inner loop program construct: A faster way for program execution
title_fullStr Inner loop program construct: A faster way for program execution
title_full_unstemmed Inner loop program construct: A faster way for program execution
title_short Inner loop program construct: A faster way for program execution
title_sort inner loop program construct a faster way for program execution
topic for loop
while loop
programming languages
windows 10
optimisation
url http://www.degruyter.com/view/j/comp.2018.8.issue-1/comp-2018-0004/comp-2018-0004.xml?format=INT
work_keys_str_mv AT adewumitosinp innerloopprogramconstructafasterwayforprogramexecution