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

From: Bum-Seok Hyun <dominic AT gong DOT snu DOT ac DOT kr>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: [Q]Computing speed in C++
Date: Wed, 04 Mar 1998 19:48:20 +0900
Organization: Seoul National University, Republic of Korea
Lines: 52
Message-ID: <34FD3174.2401F904@gong.snu.ac.kr>
References: <34FCB769 DOT 42BEF1A8 AT gong DOT snu DOT ac DOT kr>
NNTP-Posting-Host: davinci3.snu.ac.kr
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Scott Warner wrote:

> Just out of curiosity, what's the code?  Did you compile and link C
code as though it were C++?
>
> There isn't that much difference between the two afaik, but individual
linking libraries could be different.
>
> > So I made a test for comparing computing time.
> > The result is
> > c code         : 21 sec
> > c++ code       : 57 sec
> > Fortran77 code : 115 sec
> >
> > 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