delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/04/16:46:07

Date: Wed, 4 Mar 1998 16:42:59 -0500 (EST)
Message-Id: <199803042142.QAA02942@p2.acadia.net>
To: Bum-Seok Hyun <dominic AT gong DOT snu DOT ac DOT kr>
Subject: Re: [Q]Computing speed in C++
Cc: djgpp AT delorie DOT com
References: <34FCB769 DOT 42BEF1A8 AT gong DOT snu DOT ac DOT kr> <199803040910 DOT EAA08076 AT p2 DOT acadia DOT net> <34FD2F86 DOT E3DCCB5D AT gong DOT snu DOT ac DOT kr>
in-reply-to: <34FD2F86.E3DCCB5D@gong.snu.ac.kr>
From: swarnerx3 AT acadia DOT net (Scott Warner)
MIME-Version: 1.0

Interesting!

AFAIK, djgpp is a good optimizing compiler, but there may be something funny happening with your in-loop declarations.  (Although my guess is that gxx is gcc with different libraries.)  The program may have to continuously reallocate the heap (if that's the precise term).  I suggest trying the identical code in C and C++, so you're comparing apples and apples.

> > > The test code is quite simple, consisted of 3 nested "for" loops.
> >
>
> Let me first thank you for your kind concern.
>
> Main body of my test code is
>
> for(int i=1 ; i<10001 ; i++)
>    for(int j=1 ; j<10001 ; j++)
>        for(int k=1 ; k < 11 ;  k++)  sum += i;
>
> Above code is ,of course , for C++.
>
> In C code, I just moved variable definitions
> into the first line of the code.
> Like,
>
> int i,j,k;
> float sum;
>
> That's all.
>
> I don't think that makes musch difference between C++ and C.
>
> And compile option is ,
>
> C code      :  gcc -O2 -o testc.exe testc.c
> C++ code :  gxx -O2 -o testcpp.exe testcpp.cpp
>
> And I'm using DJGPP v.2.10
>
> Did I make some mistakes or misunderstand something important?
>
> Anyway, thank you and wish you goooooooooooooooooooood Luck !!!!
>
> Bum-Seok Hyun
>  mailto:dominic AT gong DOT snu DOT ac DOT kr

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019