delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/03/15/12:15:30

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Lines: 51
X-Admin: news AT aol DOT com
From: dang2015 AT aol DOT com (DanG2015)
Newsgroups: comp.os.msdos.djgpp
Date: 15 Mar 2004 17:02:57 GMT
References: <20040315115204 DOT 08910 DOT 00001403 AT mb-m13 DOT aol DOT com>
Organization: AOL http://www.aol.com
Subject: Re: new / delete efficiency in deque
Message-ID: <20040315120257.22770.00001366@mb-m10.aol.com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

>Just for grins, I wanted to see how often deque would exercise new / delete.

BTW... I compiled that test snippet under Windows VC6 and it called new/delete
upon EVERY push() and pop() operation!

However, it appears that WIN is cleaning up the empty deque after I pop,
because
there's a huge malloc(4080) each time:
======win output=========
malloc (4080)=003261F8
malloc (8)=00430330
+delete 003261F8
delete 00430330
-  malloc (4080)=003261F8
malloc (8)=00430330
+delete 003261F8
delete 00430330
-  malloc (4080)=003261F8

[snip]

But if I push once before starting the loop so the deque never empties, then
the WIN
output is much nicer;  i.e.:
    D.push_back( 1 );
    for ( ...200... ) {
           D.push_back( 1 );
           D.pop_front( );
     }

WIN then generates this:
malloc (4096)=003251C0
malloc (8)=00430090
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
+-+-+-
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
+-+-+-
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
+-+-+-
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
+-+-+-
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
+-+-+-

delete 003251C0
delete 00430090

But the DJGPP version still has that funny delete / new operation about 3/4 of
the way through the 200-times loop, even if I keep the deque from emptying.

Dan

- Raw text -


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