title: C++ Performance with/without "cout"
body: <p>Hello guys and girls. </p>
  
  <p>My question is simple one but I have no answer. Below you can see my C++ code - it is a little bit big but simple - when I run the code with <code>//std::cout&lt;&lt;yy&lt;&lt;endl; (commented)</code> it run less than 1 second, when I un-comment that line it runs about 2 minutes (I speak about Release because in Debug it run more time). Please pay attention that that line produce only few output lines (so the problem is not that the program have to call "cout" too many times) Thank you all. Here is my code:</p>
  
  <pre><code>#include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  struct cell {
      int x;
      int y;
  };
  
  int main(int argc, char** argv) {
      cell vector[8];
      unsigned long int yy=0;
  
      for (int aaa = 0; aaa &lt; 8; aaa++) {
          vector[0].x = aaa;
          for (int aab = 0; aab &lt; 8; aab++) {
              vector[0].y = aab;
              for (int aac = 0; aac &lt; 8; aac++) {
                  vector[1].x = aac;
                  for (int aad = 0; aad &lt; 8; aad++) {
                      vector[1].y = aad;
                      for (int aae = 0; aae &lt; 8; aae++) {
                          vector[2].x = aae;
                          for (int aaf = 0; aaf &lt; 8; aaf++) {
                              vector[2].y = aaf;
                              for (int aag = 0; aag &lt; 8; aag++) {
                                  vector[3].x = aag;
                                  for (int aah = 0; aah &lt; 8; aah++) {
                                      vector[3].y = aah;
                                      for (int aai = 0; aai &lt; 8; aai++) {
                                          vector[4].x = aai;
                                          for (int aaj = 0; aaj &lt; 8; aaj++) {
                                              vector[4].y = aaj;
                                              for (int aak = 0; aak &lt; 8; aak++) {
                                                  vector[5].x = aak;
                                                  for (int aal = 0; aal &lt; 8; aal++) {
                                                      vector[5].y = aal;
                                                                      yy++;
                                                                      if(yy%10000000000==0){
                                                                      vector[5].y = aal-1;
                                                                      //std::cout&lt;&lt;yy&lt;&lt;endl;
                                                                      }
  
                                                  }
                                              }
                                          }
                                      }
                                  }
                              }
                          }
                      }
                  }
              }
          }
      }
      std::cout&lt;&lt;yy&lt;&lt;endl;
      std::cout&lt;&lt;vector[5].y&lt;&lt;endl;
      return 0;
  }
  </code></pre>