[Dev-C++] running time of algorithms
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Anton T. <ant...@ch...> - 2001-09-27 07:24:12
|
hi, Urmila calculating the time of an algorithm can be difficult and also depends = on the hardware and software environment. but you can measure the time = using a system clock, for example under Win32: int started; int runtime; started =3D GetTickCount(); // started =3D milliseconds since win was = started my_algorithm(); runtime =3D GetTickCount() - started; now 'runtime' holds the number of milliseconds elapsed. if the = resolution is poor, just call 'my_algorithm' many times: int started; int runtime; started =3D GetTickCount(); // started =3D milliseconds since win was = started for (int i =3D 0; i < 1000000; i++) my_algorithm(); runtime =3D GetTickCount() - started; hope this could help. anton tichawa. ----- Original Message -----=20 From: Urmila Samanta <ums...@cc...> To: <dev...@li...> Sent: Thursday, September 27, 2001 12:03 AM Subject: [Dev-C++] Re: Dev-cpp-users digest, Vol 1 #433 - 3 msgs > Hi, >=20 > My name is Urmila. I want to know if in C++ there is a built in > function > that will calculate the running time of an algorithm, and if so how do > you use it? >=20 > Urmila >=20 > On > Wed, 26 Sep 2001 dev...@li... wrote: >=20 > > Send Dev-cpp-users mailing list submissions to > > dev...@li... > >=20 > > To subscribe or unsubscribe via the World Wide Web, visit > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > or, via email, send a message with subject or body 'help' to > > dev...@li... > >=20 > > You can reach the person managing the list at > > dev...@li... > >=20 > > When replying, please edit your Subject line so it is more specific > > than "Re: Contents of Dev-cpp-users digest..." > >=20 > >=20 > > Today's Topics: > >=20 > > 1. RE: C++ standard - Nesting classes. (Ioannis Vranos) > > 2. RE: C++ standard - Nesting classes. (Ioannis Vranos) > > 3. Building DLLs (Rodrigo Hjort) > >=20 > > --__--__-- > >=20 > > Message: 1 > > From: "Ioannis Vranos" <no...@ya...> > > To: <dev...@li...> > > Subject: RE: [Dev-C++] C++ standard - Nesting classes. > > Date: Wed, 26 Sep 2001 20:33:01 +0200 > > Reply-To: dev...@li... > >=20 > > Win32 API is old, MFC is old. .NET will have a different system call > > class hierarchy called BCL (Base Class Library). So why learn legacy > > stuff? > >=20 > > For now, if you can't wait for .NET i suggest you Borland C++ = Builder > > and its class hierarchy called VCL (Visual Class Library). It is a = lot > > higher level than MFC/Win32 crap. For accuracy it is a very high = level > > Win32 wrapper. It covers anything and you will probably never need = to > > write win32 crap. Also, Borland RAD/VCL is more high level than the > > RAD/BCL which will come with Visual Studio 7 and .NET in general. > > Dev-C++ does not cover of course VCL, but i am telling you the best > > solution for Windows programming (the best thing for you) for now. = The > > book "C++ Builder 5 Developer's Guide" by Sams Publishing comes with = a > > trial version of the Borland's IDE and this is also the book i = suggest > > you read for this particular IDE. > >=20 > > As for "The C++ Programming Language" 3rd edition or special = edition, > > i suggest you read it all from cover to cover (although it will take > > about 1-2 years). Reading for example 2-3 pages/day is a good speed, > > with no much brain overhead and what you learn will not get wasted = since > > C++ will not change. :) > >=20 > >=20 > > Ioannis > >=20 > > * Ioannis Vranos > > * Programming pages: http://www.noicys.f2s.com > > * Alternative URL: http://run.to/noicys > >=20 > >=20 > > > -----Original Message----- > > > From: dev...@li...=3D20 > > > [mailto:dev...@li...] On Behalf=3D20 > > > Of Jason Hardman > > > Sent: Wednesday, September 26, 2001 5:29 PM > > > To: dev...@li... > > > Subject: Re: [Dev-C++] C++ standard - Nesting classes. > > >=3D20 > > >=3D20 > > > Perhaps I should have been a little more clearer in the=3D20 > > > wording I used. What am doing is declaring one class which is=3D20 > > > the primary class that provides the functionality I am coding=3D20 > > > (a glorified state storage object in this case), and that=3D20 > > > class has other classes declared within it. These internal=3D20 > > > class declerations are private and so it shoudn't be possible=3D20 > > > to instantiate an object from one of these classes from=3D20 > > > outside the object. The Example from Ioannis Vranos=3D20 > > > (thanks)shows this quite well. > > >=3D20 > > > class A > > > { > > > public: > > > enum errors{MEMORY, DISK, MONITOR}; > > >=3D20 > > > private: > > > class E > > > { > > > errors e; > > >=3D20 > > > public: > > > E(errors er):e(er) {} > > > }; > > >=3D20 > > > }; > > >=3D20 > > > int main() > > > { > > > A a; > > >=3D20 > > > A::errors e; > > >=3D20 > > > A::E x(e); // Mistake, E is private > > > } > > >=3D20 > > > This compiles under Dev - C++ with MinGW, but not with=3D20 > > > Borland C++ 5.5. > > >=3D20 > > > Declaring a class doesn't create an instance of it, but AFAIK=3D20 > > > it should still be subject to the access specifier it was=3D20 > > > declared under. This is probably a known issue for MinGW,=3D20 > > > although I haven't had a chance to check that yet. > > >=3D20 > > > By the way, I already have Bjarn Stroustrup's book. I already=3D20 > > > knew how to code in C++ before getting it so never really=3D20 > > > read it all the way through, but I use it whenever I want=3D20 > > > know about the best approach to a design. It has a lot of=3D20 > > > useful information although there are easier books to use as=3D20 > > > a reference. > > >=3D20 > > > I have very little experience of Windows programming myself,=3D20 > > > but that something else I am trying to learn at this point.=3D20 > > > Any suggestions by anyone as to a good Windows API book would=3D20 > > > be appreciated by the way. Whenever I find a Windows book it=3D20 > > > is primarily about using MFC to write windows programs, but I=3D20 > > > don't have access to MFC at the moment so it's pretty useless to = me. > > >=3D20 > > > Thanks all, Jason. > > >=3D20 > > > PS: sorry about blathering on and on, I do that alot. :-D > > >=3D20 > > > ----- Original Message ----- > > > From: "Michael Codadeen" <jd...@ho...> > > > To: <dev...@li...> > > > Sent: Wednesday, September 26, 2001 8:39 AM > > > Subject: Re: [Dev-C++] C++ standard - Nesting classes. > > >=3D20 > > >=3D20 > > > > Hi Jason, > > > > > > > > The standard states that anything in your private area is = only=3D20 > > > > accessable > > > by > > > > that class. Not even public derived classes of that class=3D20 > > > can access=3D20 > > > > it. > > > > > > > > The protected area is accessable by public derived classes of = that=3D20 > > > > class. > > > In > > > > effect it becomes the private area of that derived class. = Also,=3D20 > > > > classes of the same type that get passed into an object as=3D20 > > > an argument=3D20 > > > > may have their protected area accessed. > > > > > > > > i.e. > > > > > > > > Class A { > > > > public: > > > > inline mthd(Class A& obj){cout << obj.data << endl;}; > > > > protected: > > > > data; > > > > } > > > > > > > > Class A a, b; > > > > a.mthd(b); << object a can access b protected area. > > > > > > > > The public area of a class can be accessed by anyone. > > > > > > > > The story is slightly different for protected and private = derived=3D20 > > > > classes. For more info get Stroustrups book. > > > > > > > > http://www.research.att.com/~bs/ > > > > > > > > I would not usually have a class called main, I would=3D20 > > > normally have a > > > public > > > > static main() function and tell my compiler which class = contains=3D20 > > > > main(). However, I guess this changes when you are Windows=3D20 > > > programming=3D20 > > > > of which I have no experience. > > > > > > > > Could you send an example of what you are doing so we could=3D20 > > > help some > > > more. > > > > > > > > Thanks, > > > > > > > > Michael > > > > > > > > >From: "Jason Hardman" <jas...@bt...> > > > > >Reply-To: dev...@li... > > > > >To: "Dev-C++" <dev...@li...> > > > > >Subject: [Dev-C++] C++ standard - Nesting classes. > > > > >Date: Wed, 26 Sep 2001 03:03:24 +0100 > > > > > > > > > >Hi, > > > > > > > > > >In a project I have been working on I have nested some=3D20 > > > classes within=3D20 > > > > >a main class that provides an overall functionality. I=3D20 > > > wanted to make=3D20 > > > > >these internal classes inaccessible to anyone using the=3D20 > > > main class. I=3D20 > > > > >had hoped that putting them in a private or protected area of = the=3D20 > > > > >main class it > > > would > > > > >stop outside access, but this doesn't seem to work in = Dev-C++=3D20 > > > > >(MinGW). > > > Does > > > > >anyone know if that is standard C++ behaviour? None of my=3D20 > > > C++ books=3D20 > > > > >say anything about access specifiers and nested classes,=3D20 > > > and they say=3D20 > > > > >pretty little about nested classes full-stop. It could=3D20 > > > reasonally be=3D20 > > > > >that only data and methods are affected by access specifiers, = but=3D20 > > > > >it's hard for me to be sure. > > > > > > > > > >I am now looking for an alternative way of hiding those = classes,=3D20 > > > > >although > > > I > > > > >have found some interesting options in using an = implementation=3D20 > > > > >namespace, > > > I > > > > >am still interesting in hearing any other ideas? > > > > > > > > > >Thanx, Jason. > > > > > > > > > > > > > > >_______________________________________________ > > > > >Dev-cpp-users mailing list Dev...@li... > > > > >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > > > > > > > = _________________________________________________________________ > > > > Get your FREE download of MSN Explorer at=3D20 > > > > http://explorer.msn.com/intl.asp > > > > > > > > > > > > _______________________________________________ > > > > Dev-cpp-users mailing list Dev...@li... > > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > >=3D20 > > >=3D20 > > > _______________________________________________ > > > Dev-cpp-users mailing list > > > Dev...@li... > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > >=3D20 > >=20 > >=20 > >=20 > > --__--__-- > >=20 > > Message: 2 > > From: "Ioannis Vranos" <no...@ya...> > > To: <dev...@li...> > > Subject: RE: [Dev-C++] C++ standard - Nesting classes. > > Date: Wed, 26 Sep 2001 20:34:30 +0200 > > Reply-To: dev...@li... > >=20 > > Stroustrup has a link at his pages for a pdf of a very recent draft = for > > the standard. > >=20 > >=20 > > Ioannis > >=20 > > * Ioannis Vranos > > * Programming pages: http://www.noicys.f2s.com > > * Alternative URL: http://run.to/noicys > >=20 > >=20 > > > -----Original Message----- > > > From: dev...@li...=3D20 > > > [mailto:dev...@li...] On Behalf=3D20 > > > Of Jason Hardman > > > Sent: Wednesday, September 26, 2001 4:56 PM > > > To: dev...@li... > > > Subject: Re: [Dev-C++] C++ standard - Nesting classes. > > >=3D20 > > >=3D20 > > > Thanks for that. I don't currently have any other compilers=3D20 > > > on my system so hadn't thought to check. I know that the=3D20 > > > Borland Compiler is probably the most standard compliant=3D20 > > > compiler available, so the fact that it didn't work on it=3D20 > > > probably meens it is standard. > > >=3D20 > > > I guess I'll have to inquire of the MinGW development=3D20 > > > community to see about them adding compliance. Thinking of=3D20 > > > all this I remember hearing about a website that contains a=3D20 > > > copy of the C++ standard, does anyone know where it it? I=3D20 > > > will be searching for it, but it would be easier if somebody=3D20 > > > already knows about it. > > >=3D20 > > > Thanks, Jason. > > >=3D20 > > > ----- Original Message ----- > > > From: "Ioannis Vranos" <no...@ya...> > > > To: <dev...@li...> > > > Sent: Wednesday, September 26, 2001 1:11 PM > > > Subject: RE: [Dev-C++] C++ standard - Nesting classes. > > >=3D20 > > >=3D20 > > > You are right. The following code compiles in Dev-C++: > > >=3D20 > > > class A > > > { > > > public: > > > enum errors{ MEMORY, DISK, MONITOR}; > > >=3D20 > > > private: > > > class E > > > { > > > errors e; > > >=3D20 > > > public: > > > E(errors er):e(er) {} > > > }; > > >=3D20 > > > }; > > >=3D20 > > > int main() > > > { > > > A a; > > >=3D20 > > > A::errors e; > > >=3D20 > > > A::E x(e); // Mistake, E is private > > > } > > >=3D20 > > >=3D20 > > > This shouldn't compile, so i consider it a compiler defect.=3D20 > > > Borland C++ 5.5 gives the (expected) error: > > >=3D20 > > > Error E2247 temp.cpp 23: 'A::E' is not accessible in function = main() > > > *** 1 errors in Compile *** > > >=3D20 > > >=3D20 > > > Ioannis > > >=3D20 > > > * Ioannis Vranos > > > * Programming pages: http://www.noicys.f2s.com > > > * Alternative URL: http://run.to/noicys > > >=3D20 > > >=3D20 > > >=3D20 > > > > -----Original Message----- > > > > From: dev...@li... > > > > [mailto:dev...@li...] On=3D20 > > > Behalf Of Jason=3D20 > > > > Hardman > > > > Sent: Wednesday, September 26, 2001 4:03 AM > > > > To: Dev-C++ > > > > Subject: [Dev-C++] C++ standard - Nesting classes. > > > > > > > > > > > > Hi, > > > > > > > > In a project I have been working on I have nested some=3D20 > > > classes within=3D20 > > > > a main class that provides an overall functionality. I=3D20 > > > wanted to make=3D20 > > > > these internal classes inaccessible to anyone using the=3D20 > > > main class. I=3D20 > > > > had hoped that putting them in a private or protected area=3D20 > > > of the main=3D20 > > > > class it would stop outside access, but this doesn't seem to = work > > > > in Dev-C++ (MinGW). Does anyone know if that is standard C++ > > > > behaviour? None of my C++ books say anything about access > > > > specifiers and nested classes, and they say pretty little > > > > about nested classes full-stop. It could reasonally be that > > > > only data and methods are affected by access specifiers, but > > > > it's hard for me to be sure. > > > > > > > > I am now looking for an alternative way of hiding those = classes,=3D20 > > > > although I have found some interesting options in using an=3D20 > > > > implementation namespace, I am still interesting in hearing=3D20 > > > any other=3D20 > > > > ideas? > > > > > > > > Thanx, Jason. > > > > > > > > > > > > _______________________________________________ > > > > Dev-cpp-users mailing list Dev...@li... > > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > > > >=3D20 > > >=3D20 > > > _______________________________________________ > > > Dev-cpp-users mailing list > > > Dev...@li... > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > >=3D20 > > >=3D20 > > > _______________________________________________ > > > Dev-cpp-users mailing list > > > Dev...@li... > > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > >=3D20 > >=20 > >=20 > >=20 > > --__--__-- > >=20 > > Message: 3 > > From: "Rodrigo Hjort" <rod...@ac...> > > To: "Dev-C++ Users List" <dev...@li...> > > Date: Wed, 26 Sep 2001 15:11:08 -0300 > > Subject: [Dev-C++] Building DLLs > > Reply-To: dev...@li... > >=20 > > This is a multi-part message in MIME format. > >=20 > > ------=3D_NextPart_000_0070_01C1469D.78339220 > > Content-Type: text/plain; > > charset=3D"iso-8859-1" > > Content-Transfer-Encoding: quoted-printable > >=20 > > Dear Dev-C++ users, > >=20 > > I'm trying to build a DLL to use with other applications made in = Delphi =3D > > and VB. > > The code below is a very simple DLL I tried to make using Dev-C++. > >=20 > > It compiles perfectly and creates the DLL file. > > But appears the warning: "no export definition file provided; = dllwrap =3D > > will create one, but may not be what you want". > > I noticed that it uses the file "dll.def" and modifies the name of = the =3D > > function in the DLL to "TimesTwo__Fi". > >=20 > > I created a .DEF file, which is below, that I wanted the linker to = use. =3D > > How could be this possible? > > Does anyone have a simple DLL made with Dev-C++, in C language? > >=20 > > Thanks in advance, > >=20 > > Rodrigo Hjort > > rod...@ac... > >=20 > >=20 > > **** C source code ***** > > #include <windows.h> > >=20 > > int WINAPI _export TimesTwo(int x); > > /* int extern TimesTwo(int x); */ /*also tried this*/ > >=20 > > BOOL WINAPI DllEntryPoint(HINSTANCE hinstDLL,=3D20 > > DWORD fdwReason, LPVOID lpvReserved) > > { > > switch (fdwReason) > > { > > case DLL_PROCESS_ATTACH: break; > > case DLL_THREAD_ATTACH: break; > > case DLL_PROCESS_DETACH: break; > > case DLL_THREAD_DETACH: break; > > } > > return TRUE; > > } > >=20 > > int WINAPI _export TimesTwo(int x) > > /*int extern TimesTwo(int x)*/ > > { > > return x * 2; > > } > > ************************* > >=20 > >=20 > > *** DEF file ****** > > LIBRARY Sample > > DESCRIPTION 'SAMPLE DLL' > > CODE PRELOAD MOVABLE DISCARDABLE > > DATA PRELOAD SINGLE > > EXPORTS > > TimesTwo > > ******************* > >=20 > > ------=3D_NextPart_000_0070_01C1469D.78339220 > > Content-Type: text/html; > > charset=3D"iso-8859-1" > > Content-Transfer-Encoding: quoted-printable > >=20 > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> > > <HTML><HEAD> > > <META content=3D3D"text/html; charset=3D3Diso-8859-1" =3D > > http-equiv=3D3DContent-Type> > > <META content=3D3D"MSHTML 5.00.2314.1000" name=3D3DGENERATOR> > > <STYLE></STYLE> > > </HEAD> > > <BODY bgColor=3D3D#ffffff> > > <DIV><FONT face=3D3D"Courier New" size=3D3D2> > > <DIV>Dear Dev-C++ users,</DIV> > > <DIV> </DIV> > > <DIV>I'm trying to build a DLL to use with other applications made = in =3D > > Delphi and=3D20 > > VB.</DIV> > > <DIV>The code below is a very simple DLL I tried to make using =3D > > Dev-C++.</DIV> > > <DIV> </DIV> > > <DIV>It compiles perfectly and creates the DLL file.</DIV> > > <DIV>But appears the warning: "no export definition file provided; = =3D > > dllwrap will=3D20 > > create one, but may not be what you want".</DIV> > > <DIV>I noticed that it uses the file "dll.def" and modifies the name = of =3D > > the=3D20 > > function in the DLL to "TimesTwo__Fi".</DIV> > > <DIV> </DIV> > > <DIV>I created a .DEF file, which is below, that I wanted the linker = to =3D > > use. How=3D20 > > could be this possible?</DIV> > > <DIV>Does anyone have a simple DLL made with Dev-C++, in C =3D > > language?</DIV> > > <DIV> </DIV> > > <DIV>Thanks in advance,</DIV> > > <DIV> </DIV> > > <DIV><FONT face=3D3D"Courier New" size=3D3D2>Rodrigo = Hjort<BR><A=3D20 > > = href=3D3D"mailto:rod...@ac...">rodrigo.hjort@actumplus.= co=3D > > m.br</A></FONT></DIV> > > <DIV> </DIV></FONT></DIV> > > <DIV><FONT face=3D3D"Courier New" size=3D3D2></FONT> </DIV> > > <DIV><FONT face=3D3D"Courier New" size=3D3D2>**** C source code =3D > > *****<BR>#include=3D20 > > <windows.h></FONT></DIV> > > <DIV> </DIV> > > <DIV><FONT face=3D3D"Courier New" size=3D3D2>int WINAPI _export = TimesTwo(int =3D > > x);<BR>/*=3D20 > > int extern TimesTwo(int x); */ /*also tried this*/</FONT></DIV> > > <DIV> </DIV> > > <DIV><FONT face=3D3D"Courier New" size=3D3D2>BOOL WINAPI =3D > > DllEntryPoint(HINSTANCE=3D20 > > hinstDLL, </FONT></DIV> > > <DIV><FONT face=3D3D"Courier New" size=3D3D2> = DWORD =3D > > fdwReason, LPVOID=3D20 > > lpvReserved)<BR>{<BR> switch =3D > > (fdwReason)<BR> =3D20 > > {<BR> case = DLL_PROCESS_ATTACH:=3D20 > > break;<BR> case = DLL_THREAD_ATTACH:=3D20 > > break;<BR> case = DLL_PROCESS_DETACH: =3D > >=20 > > break;<BR> case = DLL_THREAD_DETACH:=3D20 > > break;<BR> }<BR> return=3D20 > > TRUE;<BR>}</FONT></DIV> > > <DIV> </DIV> > > <DIV><FONT face=3D3D"Courier New" size=3D3D2>int WINAPI _export = TimesTwo(int =3D > > x)<BR>/*int=3D20 > > extern TimesTwo(int x)*/</FONT></DIV> > > <DIV><FONT face=3D3D"Courier New" size=3D3D2>{<BR> = return =3D > > x *=3D20 > > 2;<BR>}<BR>*************************</FONT></DIV> > > <DIV> </DIV> > > <DIV><FONT face=3D3D"Courier New" size=3D3D2><BR>*** DEF file=3D20 > > ******<BR>LIBRARY =3D20 > > Sample<BR>DESCRIPTION 'SAMPLE=3D20 > > DLL'<BR>CODE = =3D > > PRELOAD=3D20 > > MOVABLE=3D20 > > = DISCARDABLE<BR>DATA = =3D > > =3D20 > > PRELOAD=3D20 > > = SINGLE<BR>EXPORTS<BR> &nbs= =3D > > p; =3D20 > > TimesTwo<BR>*******************</FONT></DIV></BODY></HTML> > >=20 > > ------=3D_NextPart_000_0070_01C1469D.78339220-- > >=20 > >=20 > >=20 > >=20 > > --__--__-- > >=20 > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > >=20 > >=20 > > End of Dev-cpp-users Digest > >=20 >=20 >=20 > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |