# For-loop efficiency

**URL:** <https://forum.kirupa.com/t/for-loop-efficiency/245093>\
**Category:** Uncategorized\
**Created:** [November 26, 2007, 11:51am UTC](https://forum.kirupa.com/t/for-loop-efficiency/245093 "2007-11-26T11:51:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fw2803](https://avatars.discourse-cdn.com/v4/letter/f/e5b9ba/32.png) [@fw2803](https://forum.kirupa.com/u/fw2803)\
**Post date:** [November 26, 2007, 11:51am UTC](https://forum.kirupa.com/t/for-loop-efficiency/245093/1 "2007-11-26T11:51:04Z")

</div>

Hi there  
I have been thinking about the efficiency of for-loops.  
Consider the following for-loop.

```auto

for (i=0;i<1000;i++) {
  //statement1
  //statement2
  //statement3
.
.
.
  //statement10
}

```

And this one:

```auto

for (i=0;i<10;i++) {
  //statement1
  //statement2
  //statement3
.
.
.
  //statement1000
}

```

The first one has to count 1000 times but the second one has to count only 10 times.

The first one has to process only 10 statements but the second one has to process 1000 statements.

Which for-loop would occupy more CPU resources? In other words, will the value set to loop in a for-loop occupy more resources or will the number of statements in-between a for-loop occupy more resources?
